Skip to content

Instantly share code, notes, and snippets.

@n3tr
Created May 3, 2018 08:04
Show Gist options
  • Save n3tr/b254120939607be4ea9def12cbd6c598 to your computer and use it in GitHub Desktop.
Save n3tr/b254120939607be4ea9def12cbd6c598 to your computer and use it in GitHub Desktop.
const typedef = `
interface Character {
name: String
}
type Human implements Character {
name: String
}
type Robot implements Character {
name: String
engine: String
}
type Query {
allCharacters: [Character]
}
`
const resolvers = {
Character: {
__resolveType(character) {
if (character.engine) {
return 'Robot'
}
return 'Human'
}
},
Query: {
allCharacters() {
return [{ name: 'P1' }, { name: 'P2' }, { name: 'Robot1', engine: 'Fuel' }]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment