How to set a header on the response in the event of an error? #1127
Unanswered
steve-marmalade
asked this question in
Q&A
Replies: 1 comment
-
Hi. I would recommend creating custom HTTP handler for ASGI app that customizes the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi team, my use-case is that if there is an error during the processing of the GraphQL request, I would like to set the
Cache-Control
header tono-store
so that the response is not cached.I see in the Starlette docs that I can add headers to the response like in this example, but the use-case I described above is more complicated because I would need to parse the response body (which might be streamed in chunks?) and check if there is an "errors" key.
I thought the Extension.has_errors lifecycle hook would be perfect for this, but the context object that is provided does not have
response
object, so I am not sure how to set the header.Any advice would be appreciated! 🙏
Beta Was this translation helpful? Give feedback.
All reactions