summaryrefslogtreecommitdiff
path: root/tests/Language/GraphQL/ExecuteSpec.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-07-05 14:36:00 +0200
committerEugen Wissner <belka@caraus.de>2020-07-05 14:36:00 +0200
commita6f9cec413c35abdcb0d04a5550334dd2fa7d472 (patch)
treeb16ce8fd038c02ec60664f60bba8d01b08d8d218 /tests/Language/GraphQL/ExecuteSpec.hs
parentb5157e141e765c1313050cc66a2a323b67f3da79 (diff)
downloadgraphql-a6f9cec413c35abdcb0d04a5550334dd2fa7d472.tar.gz
Handle errors using custom types
Fixes #32.
Diffstat (limited to 'tests/Language/GraphQL/ExecuteSpec.hs')
-rw-r--r--tests/Language/GraphQL/ExecuteSpec.hs24
1 files changed, 11 insertions, 13 deletions
diff --git a/tests/Language/GraphQL/ExecuteSpec.hs b/tests/Language/GraphQL/ExecuteSpec.hs
index 632e4dd..e7ab9f8 100644
--- a/tests/Language/GraphQL/ExecuteSpec.hs
+++ b/tests/Language/GraphQL/ExecuteSpec.hs
@@ -47,28 +47,26 @@ spec :: Spec
spec =
describe "execute" $ do
it "skips unknown fields" $
- let expected = Aeson.object
- [ "data" .= Aeson.object
- [ "philosopher" .= Aeson.object
- [ "firstName" .= ("Friedrich" :: String)
- ]
+ let data'' = Aeson.object
+ [ "philosopher" .= Aeson.object
+ [ "firstName" .= ("Friedrich" :: String)
]
]
- execute' = execute schema (mempty :: HashMap Name Aeson.Value)
+ expected = Response data'' mempty
+ execute' = execute schema Nothing (mempty :: HashMap Name Aeson.Value)
actual = runIdentity
$ either parseError execute'
$ parse document "" "{ philosopher { firstName surname } }"
in actual `shouldBe` expected
it "merges selections" $
- let expected = Aeson.object
- [ "data" .= Aeson.object
- [ "philosopher" .= Aeson.object
- [ "firstName" .= ("Friedrich" :: String)
- , "lastName" .= ("Nietzsche" :: String)
- ]
+ let data'' = Aeson.object
+ [ "philosopher" .= Aeson.object
+ [ "firstName" .= ("Friedrich" :: String)
+ , "lastName" .= ("Nietzsche" :: String)
]
]
- execute' = execute schema (mempty :: HashMap Name Aeson.Value)
+ expected = Response data'' mempty
+ execute' = execute schema Nothing (mempty :: HashMap Name Aeson.Value)
actual = runIdentity
$ either parseError execute'
$ parse document "" "{ philosopher { firstName } philosopher { lastName } }"