diff options
| author | Danny Navarro <j@dannynavarro.net> | 2016-02-15 14:25:15 +0100 |
|---|---|---|
| committer | Danny Navarro <j@dannynavarro.net> | 2016-02-15 14:43:52 +0100 |
| commit | 98d2d41cda148cd086099f3c2c2bc2ba70d9cfba (patch) | |
| tree | c792485bf175d8d068a10996c455b3c574349ca3 /tests/Test/StarWars | |
| parent | 119f94b38e66f0e321f99b2489c3008e3585d76e (diff) | |
| download | graphql-98d2d41cda148cd086099f3c2c2bc2ba70d9cfba.tar.gz | |
Initial support for variable substitution
The correspondent end-to-end test has been ported. The variable
definition still needs to be checked.
Diffstat (limited to 'tests/Test/StarWars')
| -rw-r--r-- | tests/Test/StarWars/QueryTests.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/Test/StarWars/QueryTests.hs b/tests/Test/StarWars/QueryTests.hs index 994f7bc..6f59ec2 100644 --- a/tests/Test/StarWars/QueryTests.hs +++ b/tests/Test/StarWars/QueryTests.hs @@ -11,6 +11,7 @@ import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit (Assertion, testCase, (@?=)) import Data.GraphQL +import Data.GraphQL.Schema (Subs) import Test.StarWars.Schema @@ -20,6 +21,9 @@ import Test.StarWars.Schema testQuery :: Text -> Aeson.Value -> Assertion testQuery q expected = graphql schema q @?= Just expected +testQueryParams :: Subs -> Text -> Aeson.Value -> Assertion +testQueryParams f q expected = graphqlSubs schema f q @?= Just expected + test :: TestTree test = testGroup "Star Wars Query Tests" [ testGroup "Basic Queries" @@ -118,4 +122,17 @@ test = testGroup "Star Wars Query Tests" ] ] ] + , testCase "Luke ID with variable" . testQueryParams + (\v -> if v == "someId" + then Just "1000" + else Nothing) + [r| query FetchSomeIDQuery($someId: String!) { + human(id: $someId) { + name + } + } + |] + $ object [ + "human" .= object ["name" .= ("Luke Skywalker" :: Text)] + ] ] |
