thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API
https://graphqlite.thecodingmachine.io
MIT License
554 stars 95 forks source link

[Error handling] Remove category from exceptions #685

Closed cvergne closed 2 months ago

cvergne commented 2 months ago

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 commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

oojacoboo commented 2 months ago

@cvergne thanks for this PR!