apollo-server-plugin-operation-registry throws ForbiddenError when a forbidden operation is invoked. However, this error is responded with 500 http response code instead of 403 as in the following code:
I think these 4xx Errors should be also handled separately with proper http response code as following example:
catch (error) {
if (error instanceof HttpQueryError) {
throw error;
} else if (error instanceof AuthenticationError) {
return throwHttpGraphQLError(401, [error], options);
} else if (error instanceof ForbiddenError) {
return throwHttpGraphQLError(403, [error], options);
}
return throwHttpGraphQLError(500, [error], options);
}
It seems that we can make it work using GraphQLRequestListener and ApolloServerPlugin. Closing.
@mykevinjung could you give some example code? We are having this issue right now.
Most helpful comment
@mykevinjung could you give some example code? We are having this issue right now.