Skip to content

Errors from API returned as "Ok" when "Err" should be returned #45

Description

@entropic77

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions