Skip to content

UNAUTHORIZED exception thrown in GraphQLServletContextBuilder would end in 500 error #303

Answered by oliemansm
williamwjs asked this question in Q&A
Discussion options

You must be logged in to vote

I'd introduce a WebFilter to handle the authorization check like Spring Security does it when using the Spring ecosystem. That filter is executed before it even hits the GraphQL request processing. It'll then return a response status code of 401 or 403 outside of the GraphQL spec.

If you want to keep it inside the GraphQL spec then I'd throw a GraphQLException instead with a proper message to keep it the GraphQL way. Which is status 200 with errors field populated in the response.

I don't think the 500 error is correct tbh, but recent changes/fixes might have already corrected that.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@williamwjs
Comment options

Answer selected by williamwjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants