summaryrefslogtreecommitdiff
path: root/tests/Test/StarWars
diff options
context:
space:
mode:
authorDanny Navarro <j@dannynavarro.net>2016-02-17 12:35:54 +0100
committerDanny Navarro <j@dannynavarro.net>2016-02-17 12:35:54 +0100
commita0f12455c5b042d20773a39f9e85efbb880b65b1 (patch)
treebf82f524f2f8fdf63c091ba2d48fabe481d5a132 /tests/Test/StarWars
parent98d2d41cda148cd086099f3c2c2bc2ba70d9cfba (diff)
downloadgraphql-a0f12455c5b042d20773a39f9e85efbb880b65b1.tar.gz
Add remaining tests with variables in arguments
The test with invalid ID is commented out until proper exception handling is implemented.
Diffstat (limited to 'tests/Test/StarWars')
-rw-r--r--tests/Test/StarWars/QueryTests.hs32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/Test/StarWars/QueryTests.hs b/tests/Test/StarWars/QueryTests.hs
index 6f59ec2..1f7dc0d 100644
--- a/tests/Test/StarWars/QueryTests.hs
+++ b/tests/Test/StarWars/QueryTests.hs
@@ -2,8 +2,8 @@
{-# LANGUAGE QuasiQuotes #-}
module Test.StarWars.QueryTests (test) where
-import Data.Aeson (object, (.=))
import qualified Data.Aeson as Aeson (Value)
+import Data.Aeson (object, (.=))
import Data.Text (Text)
import Text.RawString.QQ (r)
@@ -135,4 +135,34 @@ test = testGroup "Star Wars Query Tests"
$ object [
"human" .= object ["name" .= ("Luke Skywalker" :: Text)]
]
+ , testCase "Han ID with variable" . testQueryParams
+ (\v -> if v == "someId"
+ then Just "1002"
+ else Nothing)
+ [r| query FetchSomeIDQuery($someId: String!) {
+ human(id: $someId) {
+ name
+ }
+ }
+ |]
+ $ object [
+ "human" .= object ["name" .= ("Han Solo" :: Text)]
+ ]
+ -- TODO: This test is directly ported from `graphql-js`, however do we want
+ -- to mimic the same behavior? Is this part of the spec? Once proper
+ -- exceptions are implemented this test might no longer be meaningful.
+ -- If the same behavior needs to be replicated, should it be implemented
+ -- when defining the `Schema` or when executing?
+ --
+ -- , testCase "Invalid ID" . testQueryParams
+ -- (\v -> if v == "id"
+ -- then Just "Not a valid ID"
+ -- else Nothing)
+ -- [r| query humanQuery($id: String!) {
+ -- human(id: $id) {
+ -- name
+ -- }
+ -- }
+ -- |]
+ -- $ object ["human" .= Aeson.Null]
]