Skip to content

Instantly share code, notes, and snippets.

@wharley
Created November 3, 2017 16:24
Show Gist options
  • Save wharley/ec178e3824394c155ecbd9da7e12e5e3 to your computer and use it in GitHub Desktop.
Save wharley/ec178e3824394c155ecbd9da7e12e5e3 to your computer and use it in GitHub Desktop.
const { graphql, buildSchema } = require('graphql')
// Construa um esquema, usando o idioma do esquema GraphQL
const schema = buildSchema(`
type Query {
hello: String
}
`)
// O root fornece uma função de resolução para cada endpoint da API
const root = {
hello: () => {
return 'Hello world!'
},
}
// Execute a consulta GraphQL '{hello}' e imprima a resposta
graphql(schema, '{ hello }', root).then((response) => {
console.log(response)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment