Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix __typename related test cases #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/Test/StarWars/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/Test/StarWars/QueryTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tests/Test/StarWars/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
]