summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2021-06-27 13:42:58 +0200
committerEugen Wissner <belka@caraus.de>2021-06-27 13:42:58 +0200
commitb580d1a98880749c1473c11b790d3ec622fe00ad (patch)
tree5249738121e0cf8aba3f5176e96622ff939e0520 /src
parentc601ccb4add2ca4f351af8513457c068f553b619 (diff)
downloadgraphql-b580d1a98880749c1473c11b790d3ec622fe00ad.tar.gz
Attach the field location to resolver exceptions
Diffstat (limited to 'src')
-rw-r--r--src/Language/GraphQL/Execute/Execution.hs10
1 files changed, 6 insertions, 4 deletions
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)