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). --- src/Language/GraphQL/Execute/Transform.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Language/GraphQL/Execute/Transform.hs') diff --git a/src/Language/GraphQL/Execute/Transform.hs b/src/Language/GraphQL/Execute/Transform.hs index 5e2054b..5f3b771 100644 --- a/src/Language/GraphQL/Execute/Transform.hs +++ b/src/Language/GraphQL/Execute/Transform.hs @@ -83,7 +83,7 @@ data Operation m data Field m = Field (Maybe Full.Name) Full.Name - (HashMap Full.Name Input) + (HashMap Full.Name (Full.Node Input)) (Seq (Selection m)) Full.Location @@ -278,8 +278,13 @@ field (Full.Field alias name arguments' directives' selections location) = do let field' = Field alias name fieldArguments fieldSelections location pure $ field' <$ fieldDirectives where - go arguments (Full.Argument name' (Full.Node value' _) _) = - inputField arguments name' value' + go arguments (Full.Argument name' (Full.Node value' _) location') = do + objectFieldValue <- input value' + case objectFieldValue of + Just fieldValue -> + let argumentNode = Full.Node fieldValue location' + in pure $ HashMap.insert name' argumentNode arguments + Nothing -> pure arguments fragmentSpread :: Full.FragmentSpread -- cgit v1.2.3