graphql-python / graphql-server

This is the core package for using GraphQL in a custom server easily
MIT License
120 stars 72 forks source link

Correct way to return 401 from middleware #15

Closed alexchamberlain closed 4 years ago

alexchamberlain commented 5 years ago

Is it possible to return a 401 error from middleware? I've tried raising an HTTPQueryError, but it's being intercepted and returned as JSON, with 200 status.

ProjectCheshire commented 5 years ago

@alexchamberlain Better late than never - I use to return those.


class GraphExecutionError(GraphQLError):
    def __init__(self, message, code=None, params=None):
        super().__init__(message)
        self.message = str(message)
        self.code = code
        self.params = params
``
RyanZotti commented 5 years ago

@ProjectCheshire that didn't change the response code for me. This comment suggests it's not possible to alter the response code. 200 and 500 are your only options.