From 812f6967d40cfd1d1c0af5512496ff7b7cb0f6ae Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 22 Jun 2021 09:13:27 +0200 Subject: Provide locations for argument errors The executor still doesn't give an error per argument, but a single error per field with locations for all arguments. If a non-null argument isn't specified, only the error location of the field is given. If some arguments cannot be coerced, only the locations of these arguments are given, non-null arguments are ignored. This should still be improved, so the executor returns all errors at once. The transformation tree is changed, so that argument map contains locations of the arguments (but not the locations of the argument values yet). --- tests/Language/GraphQL/ExecuteSpec.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/Language/GraphQL/ExecuteSpec.hs b/tests/Language/GraphQL/ExecuteSpec.hs index a31b0a2..5e86848 100644 --- a/tests/Language/GraphQL/ExecuteSpec.hs +++ b/tests/Language/GraphQL/ExecuteSpec.hs @@ -254,6 +254,20 @@ spec = $ parse document "" "{ philosopher { majorWork { title } } }" in actual `shouldBe` expected + it "gives location information for invalid scalar arguments" $ + let data'' = Aeson.object + [ "philosopher" .= Aeson.Null + ] + executionErrors = pure $ Error + { message = "Argument coercing failed." + , locations = [Location 1 15] + , path = [] + } + expected = Response data'' executionErrors + Right (Right actual) = either (pure . parseError) execute' + $ parse document "" "{ philosopher(id: true) { lastName } }" + in actual `shouldBe` expected + context "Subscription" $ it "subscribes" $ let data'' = Aeson.object -- cgit v1.2.3