Skip to content

[Error handling] Remove category from exceptions#685

Merged
oojacoboo merged 3 commits intothecodingmachine:masterfrom
cvergne:category-removal
May 9, 2024
Merged

[Error handling] Remove category from exceptions#685
oojacoboo merged 3 commits intothecodingmachine:masterfrom
cvergne:category-removal

Conversation

@cvergne
Copy link
Copy Markdown
Contributor

@cvergne cvergne commented May 9, 2024

As mentioned in #683, category support has already been removed from graphQL error responses with graphqlite because of graphql-php update to v15 ( see upgrade guide v14 -> v15 ), which means category is already missing from extensions in responses.

The purpose of this PR is to remove the category argument from Exceptions.

Caution

BC Break

The category argument has been removed from GraphQLException, which means any existing instance of a GraphQLException passing category and/or extensions will trigger an error.

BEFORE

throw new GraphQLException('foo', 0, null, 'MyCategory', ['field' => 'foo']);

AFTER

throw new GraphQLException('foo', 0, null, ['field' => 'foo']);

Note

If you want to keep category, you'll have two options :

  1. Creating your own GraphQLException class and using your own errorFormatter method
  2. Moving the category directly into extensions

Fixes #683

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.43%. Comparing base (53f9d49) to head (89fbc48).
Report is 84 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #685      +/-   ##
============================================
- Coverage     95.72%   95.43%   -0.30%     
- Complexity     1773     1805      +32     
============================================
  Files           154      171      +17     
  Lines          4586     4775     +189     
============================================
+ Hits           4390     4557     +167     
- Misses          196      218      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oojacoboo
Copy link
Copy Markdown
Collaborator

@cvergne thanks for this PR!

@oojacoboo oojacoboo merged commit c4a68a8 into thecodingmachine:master May 9, 2024
@cvergne cvergne deleted the category-removal branch May 10, 2024 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Error handling] Category missing in error response

3 participants