bdiasti
5/24/2019 - 3:01 AM

query e resolvers simples com graphql-yoga

import { GraphQLServer } from 'graphql-yoga'

// Type definitions (schema)
const typeDefs = `
    type Query {
        hello: String!
        name: String!
        location: String!
        bio: String!
    }
`

// Resolvers
const resolvers = {
    Query: {
        hello() {
            return 'This is my first query!'
        },
        name() {
            return 'Andrew Mead'
        },
        location() {
            return 'Philadelphia'
        },
        bio() {
            return 'I live in Philly and teach on Udemy!'
        }
    }
}

const server = new GraphQLServer({
    typeDefs,
    resolvers
})

server.start(() => {
    console.log('The server is up!')
})