git.iko.soy/rowtype-yoga/purescript-graphql
on master help sign in
Improve error messages for failed argument parsing

The error message now always contains a prefix describing which argument could not be parsed by the underlying input type.

commitcb0a97093794b0823e8b53aaa3ddf759c5f4123b authorhendrikniemann <h.neverman@web.de> dateSat 22 Feb 2020, 19:29 (7 years ago) parent0e5e39e
1 file changed+4−1
src/GraphQL/Type.purs+4−1
src/GraphQL/Type.purs+4−1
@@ -4,6 +4,7 @@ import Prelude
44
55import Control.Monad.Error.Class (class MonadError, catchError, throwError)
66import Data.Argonaut.Core as Json
7+import Data.Bifunctor (lmap)
78import Data.Either (Either(..), note)
89import Data.Enum (class Enum, enumFromTo)
910import Data.List (List, fromFoldable)
@@ -362,6 +363,8 @@ instance argsFromRowsCons ::
362363 -- Extract the argument value if the node can be found. If not use null value
363364 -- TODO: Implement default values where we would try to use the default value first
364365 valueNode = map (\(AST.ArgumentNode { value }) -> value) argumentNode
366+ improveInputError err = "Error when reading variable '" <> reflectSymbol key <> "': " <> err
367+ resolvedValue = lmap improveInputError $ argConfig.resolveValue valueNode variables
365368 tail =
366369 argsFromRows
367370 (RLProxy :: RLProxy ltargsd)
@@ -369,7 +372,7 @@ instance argsFromRowsCons ::
369372 nodes
370373 variables
371374 tailArgsDef
372− in Record.insert key <$> (argConfig.resolveValue valueNode variables) <*> tail
375+ in Record.insert key <$> resolvedValue <*> tail
373376
374377else instance argsFromRowsNil :: ArgsFromRows RL.Nil RL.Nil argsd argsp where
375378 argsFromRows _ _ _ _ _ = pure $ unsafeCoerce {}