From 98d2d41cda148cd086099f3c2c2bc2ba70d9cfba Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Mon, 15 Feb 2016 14:25:15 +0100 Subject: Initial support for variable substitution The correspondent end-to-end test has been ported. The variable definition still needs to be checked. --- tests/Test/StarWars/QueryTests.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/Test') 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)] + ] ] -- cgit v1.2.3