Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
entropic77 opened this issue Jan 8, 2024 · 0 comments
Open

Comments

@entropic77
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant