Replies: 2 comments 1 reply
-
You could set the header and it will be propagated through to the subgraphs. However, I think that you are looking for a header to be propagated back to the client. I'd implement this by setting a key in context when you know you are continuing and then check if the key is present in one of the response services (router or supergraph would be good choices). If the context key is present, then set the header there from the context value. You could do this in rhai or in your custom plugin. |
Beta Was this translation helpful? Give feedback.
-
Hey @garypen thanks for the help. Came up with something like this, does this looks rougly okay? .map_response(|mut response: supergraph::Response| {
let context_value: Result<Option<String>, BoxError> =
response.context.get(header);
if let Ok(Some(remaining_tokens)) = context_value {
let header = HeaderValue::from_str(&remaining_tokens);
if let Ok(header_value) = header {
response
.response
.headers_mut()
.append(header, header_value);
}
}
response
}) Actually, while at it, I have a question on how to test that this header is present in the response. Testing the plugin using |
Beta Was this translation helpful? Give feedback.
-
Hey,
Is it possible to set a response header in a custom rust plugin when using
ControlFlow::Continue
? Its obviously possible to do so when usingControlFlow::Break
when a new response is built, but unsure aboutContinue
.Beta Was this translation helpful? Give feedback.
All reactions