webiny-js
webiny-js copied to clipboard
Authentication error returns an invalid GraphQL response
Version
5.13.0
What steps will reproduce the bug?
It's hard to reproduce, but it will happen if you have an expired JWT token. To force this bug, add an authentication plugin which throws an error. Any error will do. The goal is to abort processing of before-handler
plugins, which goes straight into the catch
block and into handler-error
plugins.
What is the expected behavior?
The response should be formatted with { errors: [....] }
, which is a valid GraphQL response.
What do you see instead?
Response is formatted as { error: { ... } }
, which is something, but not a valid GraphQL response.
Additional information
Possible solution
Add a handler-error
plugin to handler-graphql
package, to format errors accordingly. Moreover, I suspect we'll need to reverse plugins before processing handler-error
plugins, so that the last plugin registered is the first to be executed.
Error handling plugin should be added around here: packages/handler-graphql/src/createGraphQLHandler.ts:58
This issue is stale because it was opened 120 days with no activity. Remove the "stale-issue" label or leave a comment to revive the issue. Otherwise, it will be closed in 7 days.
This issue is stale because it was opened 120 days with no activity. Remove the "stale-issue" label or leave a comment to revive the issue. Otherwise, it will be closed in 7 days.