-
Notifications
You must be signed in to change notification settings - Fork 352
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
fix: move exception handling into ktor statuspages #1936
Conversation
6bac1a0
to
0481c1d
Compare
1cf7305
to
dcb8feb
Compare
@samuelAndalon @dariuszkuc can you please take a look? 🙏 Thank you |
Maybe @smyrick ? Someone, anyone? |
Hey @curtiscook, I no longer have maintainer permissions on this repo so tagging @ExpediaGroup/graphql-kotlin-committers and @tapaderster for review. But the code change looks good to me 👍🏻 |
I believe by changing error handling behavior you will force compatibility with GraphQL over HTTP spec to the end users and the lib will no longer be able to give you those guarantees. |
I'll defer to @samuelAndalon and @tapaderster but IMHO the Spring and Ktor servers should provide users guarantees about the compliance with the GraphQL over HTTP spec. |
Per https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md:
The current implementation of catching a base exception and returning a If you're uncomfortable with this solution, one alternative could be to drop the internal visibility modifier so that it would be possible to override this error handling. As of right now, you have to rewrite the module to extend error handling. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mentioned in the PR description -> this is a breaking change in the behavior so this will have to wait for the next major release. I'll defer to @samuelAndalon when that happens but I'm guessing there will be one coming soon due to the new graphql-java
version that comes with some breaking changes (maybe there could be some alpha
pre-release before that?).
Can we also update https://github.com/ExpediaGroup/graphql-kotlin/blob/master/website/docs/server/ktor-server/ktor-overview.mdx and add new section about StatusPages
?
...r/ktor-server/src/main/kotlin/com/expediagroup/graphql/examples/server/ktor/GraphQLModule.kt
Outdated
Show resolved
Hide resolved
...kotlin-ktor-server/src/test/kotlin/com/expediagroup/graphql/server/ktor/GraphQLPluginTest.kt
Outdated
Show resolved
Hide resolved
dcb8feb
to
bc93fed
Compare
3db7d80
to
9aa9575
Compare
...otlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQLStatusPages.kt
Show resolved
Hide resolved
...otlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQLStatusPages.kt
Show resolved
Hide resolved
…group/graphql/server/ktor/GraphQLStatusPages.kt Co-authored-by: Dariusz Kuc <[email protected]>
Changes look good to me. @samuelAndalon since this is a breaking change do you want to merge lib updates first and cut another v7 version before starting on the v8-alpha? |
lets do a release with this, and update dependencies in next major version, hopefully by end of this month graphql-java will release its next major version |
@curtiscook could you address the ktlint errors /home/runner/work/graphql-kotlin/graphql-kotlin/servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQLStatusPages.kt:34:60 Missing newline before "}"
/home/runner/work/graphql-kotlin/graphql-kotlin/servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQLStatusPages.kt:34:62 Missing newline before "}" |
9312318
to
4f497dc
Compare
Will merge it after #1951 |
📝 Description
Currently, the Ktor version of the GraphQL server swallows a base exception, which disallows any custom error responses. This PR moves exception handling to statuspages, which is the recommended error handler.
Note: This is a breaking change for people relying on the current functionality to handle errors
🔗 Related Issues
#1920