From b580d1a98880749c1473c11b790d3ec622fe00ad Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 27 Jun 2021 13:42:58 +0200 Subject: Attach the field location to resolver exceptions --- src/Language/GraphQL/Execute/Execution.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Language/GraphQL/Execute/Execution.hs b/src/Language/GraphQL/Execute/Execution.hs index c2a2d97..9ad4439 100644 --- a/src/Language/GraphQL/Execute/Execution.hs +++ b/src/Language/GraphQL/Execute/Execution.hs @@ -37,15 +37,17 @@ resolveFieldValue :: MonadCatch m => Type.Value -> Type.Subs -> Type.Resolve m + -> Full.Location -> CollectErrsT m Type.Value -resolveFieldValue result args resolver = +resolveFieldValue result args resolver location' = catch (lift $ runReaderT resolver context) handleFieldError where handleFieldError :: MonadCatch m => ResolverException -> CollectErrsT m Type.Value - handleFieldError e = - addError Type.Null $ Error (Text.pack $ displayException e) [] [] + handleFieldError e + = addError Type.Null + $ Error (Text.pack $ displayException e) [location'] [] context = Type.Context { Type.arguments = Type.Arguments args , Type.values = result @@ -106,7 +108,7 @@ executeField fieldResolver prev fields Left errorLocations -> addError null $ Error "Argument coercing failed." errorLocations [] Right argumentValues -> do - answer <- resolveFieldValue prev argumentValues resolver + answer <- resolveFieldValue prev argumentValues resolver location' completeValue fieldType fields answer completeValue :: (MonadCatch m, Serialize a) -- cgit v1.2.3