Replies: 2 comments 6 replies
-
The proposed solution looks a bit too complex I think. I would opt for the simpler way, and be able to set the headers in the actual operation hook, it's much better for discoverability and maintainability. |
Beta Was this translation helpful? Give feedback.
2 replies
-
I think this is a commonly used feature, do you have any plans to implement it? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Situation
Set-Cookie
headerProblem
Currently, it's possible to do all kinds of things to "inject" data into origin requests.
However, we're quite un-flexible when it comes to returning data from a single origin request back to the client.
If data is part of the response body, it's ok, but headers are a problem.
So, ideally, we could add a hook for one specific operation and "forward" an origin response header to the client response.
However, this leads to another problem. We're only able to set a single origin hook.
If we configure an origin hook, it's applied to all operations.
That's a massive overhead because it means another round-trip and function call,
unnecessary most of the time.
To sum up the acceptance criteria:
Current implementation of on origin response hook
https://docs.wundergraph.com/docs/wundergraph-server-ts-reference/on-origin-response-hook
Solution
The proposed solution below:
It's worth noting, as you might overlook this, that I've made
onOriginResponse
an array instead of an object.This means, there can be multiple such hooks, each applied to different operations.
Simpler way
Another option would be to just add a function to the hook context, like
setClientResponseHeader(key, value)
;Beta Was this translation helpful? Give feedback.
All reactions