Created
May 3, 2018 08:04
-
-
Save n3tr/b254120939607be4ea9def12cbd6c598 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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