Skip to content

Update default exception handler to use SimpleKotlinGraphQLError #369

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

Merged
merged 1 commit into from
Sep 23, 2019

Conversation

dariuszkuc
Copy link
Collaborator

📝 Description

By default, our default exception handler was wrapping all the runtime exceptions in graphql-java ExceptionWhileDataFetching GraphQLError. Since this default GraphQL error exposes exception field it was also getting serialized in the response. While this is was still valid GraphQL response, per spec exception field is not part of the defined error fields and instead should be included in the error extensions entry field instead (if at all).

Note: the above serialization issue could also be solved by using graphql-java ExecutionResult#toSpecification method to generate final results but that would also imply that we would need to return Map instead of a GraphQLResponse.

🔗 Related Issues

#366 - [question] how to disable stacktrace in error responses

By default, our default exception handler was wrapping all the runtime exceptions in `graphql-java` `ExceptionWhileDataFetching` GraphQLError. Since this default GraphQL error exposes `exception` field it was also getting serialized in the response. While this is was still valid GraphQL response, per [spec](https://graphql.github.io/graphql-spec/June2018/#sec-Errors) `exception` field is not part of the defined error fields and instead should be included in the error `extensions` entry field instead (if at all).

Note: the above serialization issue could also be solved by using `graphql-java` `ExecutionResult#toSpecification` method to generate final results but that would also imply that we would need to return `Map` instead of a `GraphQLResponse`.
@codecov-io
Copy link

codecov-io commented Sep 23, 2019

Codecov Report

Merging #369 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #369   +/-   ##
=========================================
  Coverage     94.46%   94.46%           
  Complexity      323      323           
=========================================
  Files            97       97           
  Lines          1139     1139           
  Branches        204      204           
=========================================
  Hits           1076     1076           
  Misses           22       22           
  Partials         41       41
Impacted Files Coverage Δ Complexity Δ
...ing/exception/KotlinDataFetcherExceptionHandler.kt 25% <0%> (ø) 1 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cb7ed1...d5798ce. Read the comment docs.

@smyrick smyrick merged commit 03a881e into ExpediaGroup:master Sep 23, 2019
@smyrick smyrick added changes: patch Changes require a patch version type: enhancement New feature or request changes: minor Changes require a minor version and removed changes: patch Changes require a patch version labels Sep 23, 2019
@dariuszkuc dariuszkuc deleted the exceptions branch September 24, 2019 16:46
dariuszkuc added a commit to dariuszkuc/graphql-kotlin that referenced this pull request Aug 5, 2022
…ediaGroup#369)

By default, our default exception handler was wrapping all the runtime exceptions in `graphql-java` `ExceptionWhileDataFetching` GraphQLError. Since this default GraphQL error exposes `exception` field it was also getting serialized in the response. While this is was still valid GraphQL response, per [spec](https://graphql.github.io/graphql-spec/June2018/#sec-Errors) `exception` field is not part of the defined error fields and instead should be included in the error `extensions` entry field instead (if at all).

Note: the above serialization issue could also be solved by using `graphql-java` `ExecutionResult#toSpecification` method to generate final results but that would also imply that we would need to return `Map` instead of a `GraphQLResponse`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: minor Changes require a minor version type: enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants