-
Notifications
You must be signed in to change notification settings - Fork 259
@apollo/gateway - Expose the current request query path to the "willSendRequest" and "didReceiveResponse" hooks #2384
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
Changes from 13 commits
e3078e2
049cb7b
bdb1771
e1db4fe
a629b6a
255c52a
b87d16e
e098c73
824e642
7b94685
aa92d13
d829f0d
b4aa810
2da416c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@apollo/gateway": patch | ||
--- | ||
|
||
Exposes, for each subgraph request, the path in the overall gateway operation at which that subgraph request gets inserted. This path is now available as the pathInIncomingRequest field in the arguments of RemoteGraphQLDataSource.willSendRequest and RemoteGraphQLDataSource.didReceiveResponse. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { ResponsePath } from '@apollo/query-planner'; | ||
import { GatewayGraphQLResponse, GatewayGraphQLRequestContext } from '@apollo/server-gateway-interface'; | ||
|
||
export interface GraphQLDataSource< | ||
|
@@ -47,6 +48,12 @@ export type GraphQLDataSourceProcessOptions< | |
* this will increase the memory used by the gateway query plan cache. | ||
*/ | ||
document?: GatewayGraphQLRequestContext<TContext>['document']; | ||
|
||
/** | ||
* The path in the overall gateway operation at which that subgraph request gets inserted. | ||
* Please note that this could be set to `undefined` when the path is not available, or set to `null` for top-level fetch operations. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe the "or set to What I mean/understand by "top-level" fetch operations is just subgraph fetches that are not entity fetches but rather query some Your current patch sets There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry. Misunderstood. Got you now. |
||
*/ | ||
pathInIncomingRequest?: ResponsePath | null; | ||
} | ||
| { | ||
kind: | ||
|
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.
I don't think we need that test (we can use
options.pathInIncomingRequest
directly): it's going to beundefined
for non-INCOMING_OPERATION
, but that feels almost more appropriate, and that avoids having to deal withnull
at all.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.
I changed the

null
assignment toundefined
, however, I cannot useoptions.pathInIncomingRequest
directly because thepathInIncomingRequest
property is not guaranteed to exist inoptions
because of the usage of typescript's union operator:therefore, I must verify
options.kind
before using it, unless you can think of another approach?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.
Oh, correct, this is my bad.