Skip to content

Instantly share code, notes, and snippets.

@davazp
Created June 29, 2017 07:51
Show Gist options
  • Save davazp/4595dfe1334b141afd70c9caa96d0acf to your computer and use it in GitHub Desktop.
Save davazp/4595dfe1334b141afd70c9caa96d0acf to your computer and use it in GitHub Desktop.
'use strict';
const graphql = require('graphql').graphql;
const makeExecutableSchema = require('graphql-tools').makeExecutableSchema;
let resolvers = {
Query: {
person: ()=>{
return {
id: 2
};
}
},
Person: {
name: (person, args)=>{
if (person.id==1){
return "david";
} else
return "i dont know";
}
}
};
let schema = makeExecutableSchema({
typeDefs: `
type Query {
person: Person
}
type Person {
name: String
}
`,
resolvers
});
graphql(schema, `{
person {
name
}
}`).then(result=>{
console.dir(result, {depth: null, color: true});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment