Skip to content

Commit

Permalink
Provide new requestIsBatched field to gateway compatibility layer (#7118
Browse files Browse the repository at this point in the history
)

This field was added today in v3.11.0 and v4.1.0. That means that if you
installed an older version of Gateway that gets its types from AS3
rather than from `@apollo/server-gateway-interface` it would suddenly
start expecting this field on its GraphQLRequestContext.

We fixed that problem by releasing v3.11.1 which makes the field
optional. But it still seems reasonable to provide it if it's
available... but we keep the field optional in the compatibility
interface so that new Gateway doesn't end up requiring new Server.
  • Loading branch information
glasser committed Nov 3, 2022
1 parent 9f7ba08 commit c835637
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/clever-camels-judge.md
@@ -0,0 +1,6 @@
---
'@apollo/server-gateway-interface': patch
'@apollo/server': patch
---

Provide new `GraphQLRequestContext.requestIsBatched` field to gateways, because we did add it in a backport to AS3 and the gateway interface is based on AS3.
3 changes: 3 additions & 0 deletions packages/gateway-interface/src/index.ts
Expand Up @@ -76,6 +76,9 @@ export interface GatewayGraphQLRequestContext<TContext = Record<string, any>> {
// runtime before using it anyway, so let's just make everything build by
// declaring this as `any`.
readonly overallCachePolicy: any;
// This was only added in v3.11/v4.1, so we don't want to declare that it's
// required. (In fact, we made it optional in v3.11.1 for this very reason.)
readonly requestIsBatched?: boolean;
}

export interface GatewayGraphQLRequest {
Expand Down
Expand Up @@ -153,6 +153,7 @@ export function makeGatewayGraphQLRequestContext<TContext extends BaseContext>(
metrics: as4RequestContext.metrics,
debug: internals.includeStacktraceInErrorResponses,
overallCachePolicy: as4RequestContext.overallCachePolicy,
requestIsBatched: as4RequestContext.requestIsBatched,
};
}

Expand Down

0 comments on commit c835637

Please sign in to comment.