diff --git a/tests/Test/StarWars/Data.hs b/tests/Test/StarWars/Data.hs index cec90ae..60e8f88 100644 --- a/tests/Test/StarWars/Data.hs +++ b/tests/Test/StarWars/Data.hs @@ -62,6 +62,10 @@ secretBackstory = error "secretBackstory is secret." luke :: Character luke = Right luke' +typename :: Character -> Text +typename (Left _) = "Droid" +typename (Right _) = "Human" + luke' :: Human luke' = Human { _humanChar = CharCommon diff --git a/tests/Test/StarWars/QueryTests.hs b/tests/Test/StarWars/QueryTests.hs index dee9929..12aa540 100644 --- a/tests/Test/StarWars/QueryTests.hs +++ b/tests/Test/StarWars/QueryTests.hs @@ -251,18 +251,18 @@ test = testGroup "Star Wars Query Tests" } |] $ object ["data" .= object [ - "hero" .= ["__typename" .= ("Droid" :: Text), r2d2Name] + "hero" .= object ["__typename" .= ("Droid" :: Text), r2d2Name] ]] , testCase "Luke is a human" . testQuery [r| query CheckTypeOfLuke { - hero(episode: EMPIRE) { + hero(episode: 5) { __typename name } } |] $ object ["data" .= object [ - "hero" .= ["__typename" .= ("Human" :: Text), lukeName] + "hero" .= object ["__typename" .= ("Human" :: Text), lukeName] ]] ] , testGroup "Errors in resolvers" diff --git a/tests/Test/StarWars/Schema.hs b/tests/Test/StarWars/Schema.hs index 9021bd0..e47d284 100644 --- a/tests/Test/StarWars/Schema.hs +++ b/tests/Test/StarWars/Schema.hs @@ -43,4 +43,5 @@ character char = , Schema.array "friends" $ character <$> getFriends char , Schema.enum "appearsIn" . traverse getEpisode $ appearsIn char , Schema.scalar "secretBackstory" $ secretBackstory char + , Schema.scalar "__typename" $ typename char ]