Authorization via decorators type-graphql in combination with express-graphql throws 500 error on authorization failure #1075
Unanswered
Jackywathy
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm running into an issue when using
type-graphqlin conjunction withexpress-graphql. When I try to access an endpoint while not authorized, the server returns the appropriate error message, but with a 500 error code. An example response below:{"errors":[{"message":"Access denied! You need to be authorized to perform this action!","locations":[{"line":2,"column":3}],"path":["userDetails"]}],"data":null}I believe the reason for this is because the
dataattribute is set tonull, which is technically against the graphql spec.express-graphqlexpects data to be either not equal tonullor not present, and thus throws a 500 error. Is there any workaround to this problem? Thanks.Below is my authorization decorator code and the resolver in question, which I have applied.
Beta Was this translation helpful? Give feedback.
All reactions