-
Notifications
You must be signed in to change notification settings - Fork 2
Not able to access headers object from apollo_mocks::get_supergraph_service_response() #9
Copy link
Copy link
Open
Labels
questionFurther information is requestedFurther information is requested
Description
I get the following error when accessing the headers object from the supergraph service response.
Rhai script is forwarding the custom response headers from subgraphs to the client.
"
Unknown property 'headers' - a getter is not registered for type 'alloc::sync::Arc<std::sync::mutex::Mutex<core::option::Option<apollo_router::services::supergraph::Response>>>'
"
response-header-forwarder.rhai:
// Configure allowed response headers
fn getAllowedResponseHeaders() {
["custom_response_header"]
}
fn copyResponseHeadersInResponse(response) {
for header in getAllowedResponseHeaders() {
if response.context[header]!=() {
response.headers[header] = response.context[header];
}
}
}
response-header-forwarder.test.rhai:
test("Validate response header", ||{
let mockResponse = apollo_mocks::get_supergraph_service_response();
mockResponse.context["custom_response_header"]= "custom header value";
const execute = || {
import "response-header-forwarder" as responseHeaderForwarder;
responseHeaderForwarder::copyResponseHeadersInResponse(mockResponse);
};
execute.call();
expect(mockResponse.headers["custom_response_header"]).to_be("custom header value");
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested