forked from OSS/graphql
Fix values not being coerced to lists
This commit is contained in:
parent
2fdf04f54a
commit
97d304d283
@ -106,4 +106,6 @@ test-suite graphql-test
|
|||||||
unordered-containers,
|
unordered-containers,
|
||||||
containers,
|
containers,
|
||||||
vector
|
vector
|
||||||
|
build-tool-depends:
|
||||||
|
hspec-discover:hspec-discover
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
@ -556,33 +556,24 @@ coerceArgumentValues argumentDefinitions argumentValues =
|
|||||||
$ Just inputValue
|
$ Just inputValue
|
||||||
| otherwise -> throwM
|
| otherwise -> throwM
|
||||||
$ InputCoercionException (Text.unpack argumentName) variableType Nothing
|
$ InputCoercionException (Text.unpack argumentName) variableType Nothing
|
||||||
|
|
||||||
matchFieldValues' = matchFieldValues coerceArgumentValue
|
matchFieldValues' = matchFieldValues coerceArgumentValue
|
||||||
$ Full.node <$> argumentValues
|
$ Full.node <$> argumentValues
|
||||||
coerceArgumentValue inputType (Transform.Int integer) =
|
|
||||||
coerceInputLiteral inputType (Type.Int integer)
|
coerceArgumentValue inputType transform =
|
||||||
coerceArgumentValue inputType (Transform.Boolean boolean) =
|
coerceInputLiteral inputType $ extractArgumentValue transform
|
||||||
coerceInputLiteral inputType (Type.Boolean boolean)
|
|
||||||
coerceArgumentValue inputType (Transform.String string) =
|
extractArgumentValue (Transform.Int integer) = Type.Int integer
|
||||||
coerceInputLiteral inputType (Type.String string)
|
extractArgumentValue (Transform.Boolean boolean) = Type.Boolean boolean
|
||||||
coerceArgumentValue inputType (Transform.Float float) =
|
extractArgumentValue (Transform.String string) = Type.String string
|
||||||
coerceInputLiteral inputType (Type.Float float)
|
extractArgumentValue (Transform.Float float) = Type.Float float
|
||||||
coerceArgumentValue inputType (Transform.Enum enum) =
|
extractArgumentValue (Transform.Enum enum) = Type.Enum enum
|
||||||
coerceInputLiteral inputType (Type.Enum enum)
|
extractArgumentValue Transform.Null = Type.Null
|
||||||
coerceArgumentValue inputType Transform.Null
|
extractArgumentValue (Transform.List list) =
|
||||||
| In.isNonNullType inputType = Nothing
|
Type.List $ extractArgumentValue <$> list
|
||||||
| otherwise = coerceInputLiteral inputType Type.Null
|
extractArgumentValue (Transform.Object object) =
|
||||||
coerceArgumentValue (In.ListBaseType inputType) (Transform.List list) =
|
Type.Object $ extractArgumentValue <$> object
|
||||||
let coerceItem = coerceArgumentValue inputType
|
extractArgumentValue (Transform.Variable variable) = variable
|
||||||
in Type.List <$> traverse coerceItem list
|
|
||||||
coerceArgumentValue (In.InputObjectBaseType inputType) (Transform.Object object)
|
|
||||||
| In.InputObjectType _ _ inputFields <- inputType =
|
|
||||||
let go = forEachField object
|
|
||||||
resultMap = HashMap.foldrWithKey go (pure mempty) inputFields
|
|
||||||
in Type.Object <$> resultMap
|
|
||||||
coerceArgumentValue _ (Transform.Variable variable) = pure variable
|
|
||||||
coerceArgumentValue _ _ = Nothing
|
|
||||||
forEachField object variableName (In.InputField _ variableType defaultValue) =
|
|
||||||
matchFieldValues coerceArgumentValue object variableName variableType defaultValue
|
|
||||||
|
|
||||||
collectFields :: Monad m
|
collectFields :: Monad m
|
||||||
=> Out.ObjectType m
|
=> Out.ObjectType m
|
||||||
|
Loading…
Reference in New Issue
Block a user