Implement type instrospection tests

The main intention with this commit is to show a poor's man way to support type
instrospection.
This commit is contained in:
Danny Navarro
2017-03-01 22:04:13 -03:00
parent 6a10e28ba8
commit 285ccb0af9
3 changed files with 11 additions and 10 deletions

View File

@ -19,7 +19,10 @@ schema = hero :| [human, droid]
hero :: Alternative f => Resolver f
hero = Schema.objectA "hero" $ \case
[] -> character artoo
[Argument "episode" (ValueInt n)] -> character . getHero $ fromIntegral n
[Argument "episode" (ValueInt n)] -> character . getHero $ fromIntegral n
[Argument "episode" (ValueEnum "NEWHOPE")] -> character $ getHero 4
[Argument "episode" (ValueEnum "EMPIRE" )] -> character $ getHero 5
[Argument "episode" (ValueEnum "JEDI" )] -> character $ getHero 6
_ -> empty
human :: Alternative f => Resolver f
@ -40,4 +43,5 @@ character char =
, Schema.enum "appearsIn" . traverse getEpisode $ appearsIn char
, Schema.scalar "secretBackstory" $ secretBackstory char
, Schema.scalar "homePlanet" $ either mempty homePlanet char
, Schema.scalar "__typename" $ typeName char
]