Initial support for variable substitution

The correspondent end-to-end test has been ported. The variable
definition still needs to be checked.
This commit is contained in:
Danny Navarro
2016-02-15 14:25:15 +01:00
parent 119f94b38e
commit 98d2d41cda
4 changed files with 54 additions and 21 deletions

View File

@ -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)]
]
]