You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A mutation inheriting from the BaseWriteMutation should report errors in the errors field of the mutation type. This currently does not happen; the mutation type is instead returned as an empty object.
Reproduction
I've reproduced this issue in the linked branch fix/graphql-mutations-errors. I basically created a mutation that will always throw an exception, as well as a test that asserts that the error field is present in the mutation payload. You can see the test error in the workflow. Here's the assertion error:
You can see that the test tries to make sure the errors field is in the payload and fails because it doesn't find anything present.
Solution
I think a temporary solution I will use for now is to make the GraphQL mutation return type fields required. In this case, when there is an error the errors field will at least contain something, so it's possible to check when an exception has been thrown.
I'm not sure what the best long-term solution would be.
The text was updated successfully, but these errors were encountered:
david-code
changed the title
Bug:
Bug: GraphQL "BaseMutation" does not report errors properly
Apr 3, 2023
Description
A mutation inheriting from the
BaseWriteMutation
should report errors in theerrors
field of the mutation type. This currently does not happen; the mutation type is instead returned as an empty object.Reproduction
I've reproduced this issue in the linked branch fix/graphql-mutations-errors. I basically created a mutation that will always throw an exception, as well as a test that asserts that the error field is present in the mutation payload. You can see the test error in the workflow. Here's the assertion error:
You can see that the test tries to make sure the
errors
field is in the payload and fails because it doesn't find anything present.Solution
I think a temporary solution I will use for now is to make the GraphQL mutation return type fields required. In this case, when there is an error the
errors
field will at least contain something, so it's possible to check when an exception has been thrown.I'm not sure what the best long-term solution would be.
The text was updated successfully, but these errors were encountered: