-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access context in rewriteHeaders #454
Access context in rewriteHeaders #454
Conversation
lib/gateway/service-map.js
Outdated
@@ -85,7 +85,8 @@ async function getRemoteSchemaDefinition (serviceConfig, initHeaders) { | |||
} | |||
` | |||
}), | |||
headers | |||
headers, | |||
context: {} // No context to pass at this stage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there's no context, do we need to provide a fake one then or would leaving it undefined be a more sensible default than providing an empty object then?
@@ -0,0 +1,101 @@ | |||
'use strict' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I'm missing it, but I don't see where this file tests that rewriteHeaders is actually called and, more importantly, that its return value is actually used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests to rewriteHeaders
are at line 64 and 65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, see inline comment.
Co-authored-by: Simone Busoli <simone.busoli@gmail.com>
@alex-parra @mcollina
My use-case is auth on gateway side and sending context to services via For now I have to implement auth on all services, even which don't use database for its methods. It's a huge overhead in packages and runtime, when one query using 3-5 services and every of them should auth. Is it possible to get data from context method to |
I think it should be the same context. Please open a new issue with a full reproducible example. Thanks. |
I am sorry, problem was because sometimes context is undefined. I haven't expected such value and it led to error on request its fields. |
Fix #431
On gateway setups, query
context
was not being exposed torewriteHeaders
.This PR fixes the issue by passing the
context
to every call toserviceDefinition.sendRequest
which then exposes it torewriteHeaders
as an additional parameter.