-
-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returning a 401 response #1632
Comments
I have been looking at converting some existing code from starlette/graphene/fastapi to strawberry/fastapi. from fastapi import APIRouter, FastAPI, Request
from starlette.graphql import GraphQLApp
app = FastAPI()
router = APIRouter()
@router.api_route("/graphql", methods=["GET", "POST"])
async def _route_with_auth(request: Request):
authenticate(request)
# ... authenticate() raises a HttpException(status_code=401) if the authorization header is not correct
return await GraphQLApp(schema=get_schema()).handle_graphql(
request=request)
app.include_router(router, dependencies=[]) With strawberry I struggled for some time now and did not manage to get this working. |
In addition too #1579 and this solution for Apollo Server; maybe it would be a handy feature too incorporate a 401 status error when writing auth middleware?
Upvote & Fund
The text was updated successfully, but these errors were encountered: