Created
June 29, 2017 07:51
-
-
Save davazp/4595dfe1334b141afd70c9caa96d0acf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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