Skip to content

Instantly share code, notes, and snippets.

@tomfa
Last active December 5, 2022 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomfa/a78954ca5307477e1d5bde3baf2222c3 to your computer and use it in GitHub Desktop.
Save tomfa/a78954ca5307477e1d5bde3baf2222c3 to your computer and use it in GitHub Desktop.
Demo desired ability in Apollo Router Rhai plugin
fn process_response(response) {
response.headers["set-cookie"] = "foo=bar; Domain=localhost; Path=/; Expires=Wed, 04 Jan 2023 17:25:27 GMT; HttpOnly; Secure; SameSite=None";
// This overwrites the first header set above
response.headers["set-cookie"] = "foo2=bar2; Domain=localhost; Path=/; Expires=Wed, 04 Jan 2023 17:25:27 GMT; HttpOnly; Secure; SameSite=None";
// This does not work
response.headers["set-cookie"] = [
"foo=bar; Domain=localhost; Path=/; Expires=Wed, 04 Jan 2023 17:25:27 GMT; HttpOnly; Secure; SameSite=None",
"foo2=bar2; Domain=localhost; Path=/; Expires=Wed, 04 Jan 2023 17:25:27 GMT; HttpOnly; Secure; SameSite=None",
];
}
fn supergraph_service(service) {
const response_callback = Fn("process_response");
service.map_response(response_callback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment