When the graphql-api returns an error, it will also return a list in data. This will cause elm-gql to return Ok, when it instead should return Err.
Here is an example query for Magento which will try create a user with erroneous data:
mutation createcustomer {
createCustomerV2(
input: {
firstname: "a"
lastname: "a"
email: "a"
password: "a"
}
) {
customer {
email
}
}
}
It will return:
{
"errors": [
{
"message": "\"a\" is not a valid email address.",
# ...
}
],
"data": {
"createCustomerV2": null
}
}
The problem is at
|
(Json.Decode.field "data" (Json.Decode.null ())) |
where
oneOf fails to decode the first block, and instead returns the second block. This causes the function to return
Ok instead of
Err.
When the graphql-api returns an error, it will also return a list in
data. This will cause elm-gql to returnOk, when it instead should returnErr.Here is an example query for Magento which will try create a user with erroneous data:
It will return:
The problem is at
elm-gql/src/GraphQL/Engine.elm
Line 759 in 25171c7
oneOffails to decode the first block, and instead returns the second block. This causes the function to returnOkinstead ofErr.