@apollo/gateway 2.1.0-alpha.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/datasources/LocalGraphQLDataSource.d.ts +2 -2
- package/dist/datasources/LocalGraphQLDataSource.d.ts.map +1 -1
- package/dist/datasources/RemoteGraphQLDataSource.d.ts +4 -4
- package/dist/datasources/RemoteGraphQLDataSource.d.ts.map +1 -1
- package/dist/datasources/RemoteGraphQLDataSource.js +5 -4
- package/dist/datasources/RemoteGraphQLDataSource.js.map +1 -1
- package/dist/datasources/types.d.ts +6 -6
- package/dist/datasources/types.d.ts.map +1 -1
- package/dist/executeQueryPlan.d.ts +2 -2
- package/dist/executeQueryPlan.d.ts.map +1 -1
- package/dist/executeQueryPlan.js +6 -0
- package/dist/executeQueryPlan.js.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/schema-helper/addExtensions.d.ts.map +1 -1
- package/dist/schema-helper/addExtensions.js +6 -3
- package/dist/schema-helper/addExtensions.js.map +1 -1
- package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.d.ts.map +1 -1
- package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.js.map +1 -1
- package/dist/supergraphManagers/UplinkSupergraphManager/index.d.ts +2 -2
- package/dist/supergraphManagers/UplinkSupergraphManager/index.d.ts.map +1 -1
- package/dist/supergraphManagers/UplinkSupergraphManager/index.js.map +1 -1
- package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts +1 -1
- package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts.map +1 -1
- package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.d.ts +1 -2
- package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.d.ts.map +1 -1
- package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.js.map +1 -1
- package/package.json +8 -10
- package/src/__tests__/executeQueryPlan.test.ts +143 -7
- package/src/__tests__/execution-utils.ts +3 -3
- package/src/__tests__/gateway/executor.test.ts +2 -2
- package/src/__tests__/gateway/lifecycle-hooks.test.ts +1 -1
- package/src/__tests__/integration/managed.test.ts +3 -2
- package/src/config.ts +2 -4
- package/src/datasources/LocalGraphQLDataSource.ts +2 -2
- package/src/datasources/RemoteGraphQLDataSource.ts +18 -24
- package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +2 -2
- package/src/datasources/__tests__/RemoteGraphQLDataSource.test.ts +5 -5
- package/src/datasources/types.ts +6 -6
- package/src/executeQueryPlan.ts +19 -16
- package/src/index.ts +10 -14
- package/src/logger.ts +1 -1
- package/src/schema-helper/__tests__/addExtensions.test.ts +54 -0
- package/src/schema-helper/addExtensions.ts +8 -2
- package/src/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.ts +2 -2
- package/src/supergraphManagers/UplinkSupergraphManager/__tests__/loadSupergraphSdlFromStorage.test.ts +46 -2
- package/src/supergraphManagers/UplinkSupergraphManager/index.ts +3 -3
- package/src/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.ts +5 -5
- package/src/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.ts +1 -2
- package/dist/supergraphManagers/UplinkSupergraphManager/types.d.ts +0 -9
- package/dist/supergraphManagers/UplinkSupergraphManager/types.d.ts.map +0 -1
- package/dist/supergraphManagers/UplinkSupergraphManager/types.js +0 -5
- package/dist/supergraphManagers/UplinkSupergraphManager/types.js.map +0 -1
- package/src/supergraphManagers/UplinkSupergraphManager/types.ts +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkSupergraphManager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAqD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkSupergraphManager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAqD;AAGrD,qEAA6D;AAM7D,yCAAgD;AAChD,iFAA8E;AAqC9E,MAAa,uBAAuB;IAiClC,YAAY,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,MAAM,EACN,eAAe,EACf,wBAAwB,EACxB,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,4BAA4B,EAC5B,uCAAuC,EACvC,sCAAsC,GAcvC;;QAlDe,oBAAe,GAC7B,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;QAGvC,YAAO,GAAY,eAAe,CAAC,QAAQ,EAAE,CAAC;QAE9C,qBAAgB,GACtB,uBAAuB,CAAC,0BAA0B,CAAC;QAE7C,mBAAc,GAAW,uBAAuB,CAAC,oBAAoB,CAAC;QAGtE,iCAA4B,GAAY,KAAK,CAAC;QAI9C,aAAQ,GAA0B,IAAI,CAAC;QAEvC,2BAAsB,GAC5B,MAAA,OAAO,CAAC,GAAG,CAAC,oCAAoC,mCAAI,SAAS,CAAC;QAExD,eAAU,GAAW,CAAC,CAAC;QA8B7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,IAAA,yBAAgB,EAAC,KAAK,CAAC,CAAC;QAEhD,IAAI,CAAC,eAAe,GAAG,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,IAAI,CAAC,eAAe,CAAC;QAI/D,IAAI,CAAC,UAAU,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,IAAI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U,GAAE,CAAC;gBACpC,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;gBAC3C,IAAI;oBACF,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBACtE,IAAI,aAAa,EAAE;wBACjB,MAAA,IAAI,CAAC,MAAM,qDAAG,aAAa,CAAC,CAAC;qBAC9B;iBACF;gBAAC,OAAO,CAAC,EAAE;oBACV,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;iBAC1B;gBACD,cAAc,CAAC,OAAO,EAAE,CAAC;gBACzB,MAAA,IAAI,CAAC,KAAK,CAAC,gBAAgB,0CAAE,OAAO,EAAE,CAAC;aACxC;YAED,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC1B,CAAC;IAEO,gBAAgB,CAAC,CAAM;;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,gFAAgF;YAC9E,CAAC,MAAA,CAAC,CAAC,OAAO,mCAAI,CAAC,CAAC,CACnB,CAAC;IACJ,CAAC;;AA3QH,0DA4QC;AA3QwB,kDAA0B,GAAG,KAAM,CAAC;AACpC,4CAAoB,GAAG,KAAM,CAAC;AAE9B,gDAAwB,GAAG;IAChD,uCAAuC;IACvC,2CAA2C;CAC5C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SupergraphSdlUpdate } from '../../config';
|
|
2
|
+
import type { Fetcher } from '@apollo/utils.fetcher';
|
|
2
3
|
import type { Logger } from '@apollo/utils.logger';
|
|
3
|
-
import type { AbortableFetcher as Fetcher } from './types';
|
|
4
4
|
export declare const SUPERGRAPH_SDL_QUERY = "#graphql\n query SupergraphSdl($apiKey: String!, $ref: String!, $ifAfterId: ID) {\n routerConfig(ref: $ref, apiKey: $apiKey, ifAfterId: $ifAfterId) {\n __typename\n ... on RouterConfigResult {\n id\n supergraphSdl: supergraphSDL\n minDelaySeconds\n }\n ... on FetchError {\n code\n message\n }\n }\n }\n";
|
|
5
5
|
export declare class UplinkFetcherError extends Error {
|
|
6
6
|
constructor(message: string);
|
package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadSupergraphSdlFromStorage.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"loadSupergraphSdlFromStorage.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,KAAK,EAEV,OAAO,EAER,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,eAAO,MAAM,oBAAoB,wXAehC,CAAC;AAoBF,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAsB,4BAA4B,CAAC,EACjD,QAAQ,EACR,MAAM,EACN,SAAS,EACT,sBAAsB,EACtB,OAAO,EACP,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAwBvC;AAED,wBAAsB,4BAA4B,CAAC,EACjD,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,sBAAsB,EACtB,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAsGvC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { FetcherResponse } from '@apollo/utils.fetcher';
|
|
2
|
-
import { type AbortableFetcher as Fetcher } from './types';
|
|
1
|
+
import { FetcherResponse, type Fetcher } from '@apollo/utils.fetcher';
|
|
3
2
|
export declare const OUT_OF_BAND_REPORTER_QUERY = "#graphql\n mutation OOBReport($input: APIMonitoringReport) {\n reportError(report: $input)\n }\n";
|
|
4
3
|
export declare function submitOutOfBandReportIfConfigured({ error, requestEndpoint, requestBody, endpoint, response, startedAt, endedAt, tags, fetcher, }: {
|
|
5
4
|
error: Error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outOfBandReporter.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"outOfBandReporter.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAStE,eAAO,MAAM,0BAA0B,0GAItC,CAAC;AAiBF,wBAAsB,iCAAiC,CAAC,EACtD,KAAK,EACL,eAAe,EACf,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,GACR,EAAE;IACD,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,iBA6EA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outOfBandReporter.js","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.ts"],"names":[],"mappings":";;;AAEA,mEAI0C;
|
|
1
|
+
{"version":3,"file":"outOfBandReporter.js","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.ts"],"names":[],"mappings":";;;AAEA,mEAI0C;AAG7B,QAAA,0BAA0B,GAAgB;;;;CAItD,CAAC;AAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAepD,KAAK,UAAU,iCAAiC,CAAC,EACtD,KAAK,EACL,eAAe,EACf,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,GAWR;;IAEC,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO;KACR;IAED,IAAI,SAAoB,CAAC;IACzB,IAAI,CAAC,QAAQ,EAAE;QACb,SAA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ACP,2BAA2B,EAAE,IAAI;gBACjC,8BAA8B,EAAE,OAAO;gBACvC,YAAY,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE;gBAClC,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QACH,MAAM,cAAc,GAA4B,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QACzE,IAAI,CAAC,CAAA,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,0CAAE,WAAW,CAAA,EAAE;YACtC,MAAM,IAAI,KAAK,CACb,uCAAuC,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,UAAU,EAAE,CACtF,CAAC;SACH;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAA,CAAC,CAAC,OAAO,mCAAI,CAAC,EAAE,CAAC,CAAC;KAC1E;AACH,CAAC;AAjGD,8EAiGC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/gateway",
|
|
3
|
-
"version": "2.1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Apollo Gateway",
|
|
5
5
|
"author": "Apollo <packages@apollographql.com>",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,19 +25,17 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@apollo/composition": "^2.1.0
|
|
29
|
-
"@apollo/
|
|
30
|
-
"@apollo/
|
|
31
|
-
"@apollo/
|
|
28
|
+
"@apollo/composition": "^2.1.0",
|
|
29
|
+
"@apollo/federation-internals": "^2.1.0",
|
|
30
|
+
"@apollo/query-planner": "^2.1.0",
|
|
31
|
+
"@apollo/server-gateway-interface": "^1.0.2",
|
|
32
32
|
"@apollo/utils.createhash": "^1.1.0",
|
|
33
|
-
"@apollo/utils.fetcher": "^1.
|
|
33
|
+
"@apollo/utils.fetcher": "^1.1.0",
|
|
34
34
|
"@apollo/utils.isnodelike": "^1.1.0",
|
|
35
35
|
"@apollo/utils.logger": "^1.0.0",
|
|
36
36
|
"@josephg/resolvable": "^1.0.1",
|
|
37
37
|
"@opentelemetry/api": "^1.0.1",
|
|
38
38
|
"apollo-reporting-protobuf": "^0.8.0 || ^3.0.0",
|
|
39
|
-
"apollo-server-core": "^2.23.0 || ^3.0.0",
|
|
40
|
-
"apollo-server-types": "^0.9.0 || ^3.0.0",
|
|
41
39
|
"async-retry": "^1.3.3",
|
|
42
40
|
"loglevel": "^1.6.1",
|
|
43
41
|
"lru-cache": "^7.13.1",
|
|
@@ -46,7 +44,7 @@
|
|
|
46
44
|
"node-fetch": "^2.6.7"
|
|
47
45
|
},
|
|
48
46
|
"peerDependencies": {
|
|
49
|
-
"graphql": "^16.
|
|
47
|
+
"graphql": "^16.5.0"
|
|
50
48
|
},
|
|
51
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "6dec2f26af031434c56bea46a75330559dac5f5b"
|
|
52
50
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildClientSchema,
|
|
3
3
|
getIntrospectionQuery,
|
|
4
|
+
GraphQLError,
|
|
4
5
|
GraphQLObjectType,
|
|
5
6
|
print,
|
|
6
7
|
} from 'graphql';
|
|
7
8
|
import gql from 'graphql-tag';
|
|
8
|
-
import { GraphQLExecutionResult, GraphQLRequestContext } from 'apollo-server-types';
|
|
9
|
-
import { AuthenticationError } from 'apollo-server-core';
|
|
10
9
|
import { buildOperationContext } from '../operationContext';
|
|
11
10
|
import { executeQueryPlan } from '../executeQueryPlan';
|
|
12
11
|
import { LocalGraphQLDataSource } from '../datasources/LocalGraphQLDataSource';
|
|
@@ -24,6 +23,7 @@ import {
|
|
|
24
23
|
addResolversToSchema,
|
|
25
24
|
GraphQLResolverMap,
|
|
26
25
|
} from '@apollo/subgraph/src/schema-helper';
|
|
26
|
+
import {GatewayExecutionResult, GatewayGraphQLRequestContext} from '@apollo/server-gateway-interface';
|
|
27
27
|
|
|
28
28
|
expect.addSnapshotSerializer(astSerializer);
|
|
29
29
|
expect.addSnapshotSerializer(queryPlanSerializer);
|
|
@@ -45,10 +45,10 @@ describe('executeQueryPlan', () => {
|
|
|
45
45
|
async function executePlan(
|
|
46
46
|
queryPlan: QueryPlan,
|
|
47
47
|
operation: Operation,
|
|
48
|
-
executeRequestContext?:
|
|
48
|
+
executeRequestContext?: GatewayGraphQLRequestContext,
|
|
49
49
|
executeSchema?: Schema,
|
|
50
50
|
executeServiceMap?: { [serviceName: string]: LocalGraphQLDataSource }
|
|
51
|
-
): Promise<
|
|
51
|
+
): Promise<GatewayExecutionResult> {
|
|
52
52
|
const supergraphSchema = executeSchema ?? schema;
|
|
53
53
|
const operationContext = buildOperationContext({
|
|
54
54
|
schema: supergraphSchema.toAPISchema().toGraphQLJSSchema(),
|
|
@@ -63,7 +63,7 @@ describe('executeQueryPlan', () => {
|
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
async function executeOperation(operationString: string, requestContext?:
|
|
66
|
+
async function executeOperation(operationString: string, requestContext?: GatewayGraphQLRequestContext): Promise<GatewayExecutionResult> {
|
|
67
67
|
const operation = parseOp(operationString);
|
|
68
68
|
const queryPlan = buildPlan(operation);
|
|
69
69
|
return executePlan(queryPlan, operation, requestContext);
|
|
@@ -92,7 +92,7 @@ describe('executeQueryPlan', () => {
|
|
|
92
92
|
).not.toThrow();
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
function buildRequestContext():
|
|
95
|
+
function buildRequestContext(): GatewayGraphQLRequestContext {
|
|
96
96
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
97
97
|
// @ts-ignore
|
|
98
98
|
return {
|
|
@@ -126,7 +126,9 @@ describe('executeQueryPlan', () => {
|
|
|
126
126
|
overrideResolversInService('accounts', {
|
|
127
127
|
RootQuery: {
|
|
128
128
|
me() {
|
|
129
|
-
throw new
|
|
129
|
+
throw new GraphQLError('Something went wrong', {
|
|
130
|
+
extensions: { code: 'UNAUTHENTICATED' },
|
|
131
|
+
});
|
|
130
132
|
},
|
|
131
133
|
},
|
|
132
134
|
});
|
|
@@ -2936,6 +2938,140 @@ describe('executeQueryPlan', () => {
|
|
|
2936
2938
|
}
|
|
2937
2939
|
`);
|
|
2938
2940
|
});
|
|
2941
|
+
|
|
2942
|
+
test('correctly include key/typename when top-level required object is non-external', async () => {
|
|
2943
|
+
const entityTwo = {
|
|
2944
|
+
id: 'key2',
|
|
2945
|
+
external: 'v2',
|
|
2946
|
+
};
|
|
2947
|
+
const entityOne = {
|
|
2948
|
+
id: 'key1',
|
|
2949
|
+
two: { id: entityTwo.id },
|
|
2950
|
+
};
|
|
2951
|
+
|
|
2952
|
+
const s1 = {
|
|
2953
|
+
name: 'S1',
|
|
2954
|
+
typeDefs: gql`
|
|
2955
|
+
type Query {
|
|
2956
|
+
one: One
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
type One @key(fields: "id") {
|
|
2960
|
+
id: ID!
|
|
2961
|
+
two: Two
|
|
2962
|
+
computed: String @requires(fields: "two { external }")
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
type Two @key(fields: "id") {
|
|
2966
|
+
id: ID!
|
|
2967
|
+
external: String @external
|
|
2968
|
+
}
|
|
2969
|
+
`,
|
|
2970
|
+
resolvers: {
|
|
2971
|
+
Query: {
|
|
2972
|
+
one() {
|
|
2973
|
+
return entityOne;
|
|
2974
|
+
},
|
|
2975
|
+
},
|
|
2976
|
+
One: {
|
|
2977
|
+
__resolveReference(ref: { id: string }) {
|
|
2978
|
+
return ref.id === entityOne.id ? { ...entityOne, ...ref } : undefined;
|
|
2979
|
+
},
|
|
2980
|
+
computed(parent: any) {
|
|
2981
|
+
return `computed value: ${parent.two.external}`;
|
|
2982
|
+
},
|
|
2983
|
+
},
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
const s2 = {
|
|
2988
|
+
name: 'S2',
|
|
2989
|
+
typeDefs: gql`
|
|
2990
|
+
type Two @key(fields: "id") {
|
|
2991
|
+
id: ID!
|
|
2992
|
+
external: String
|
|
2993
|
+
}
|
|
2994
|
+
`,
|
|
2995
|
+
resolvers: {
|
|
2996
|
+
Two: {
|
|
2997
|
+
__resolveReference(ref: { id: string }) {
|
|
2998
|
+
return ref.id === entityTwo.id ? entityTwo : undefined;
|
|
2999
|
+
},
|
|
3000
|
+
},
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
const { serviceMap, schema, queryPlanner} = getFederatedTestingSchema([ s1, s2 ]);
|
|
3005
|
+
|
|
3006
|
+
const operation = parseOp(`
|
|
3007
|
+
{
|
|
3008
|
+
one {
|
|
3009
|
+
computed
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
`, schema);
|
|
3013
|
+
const queryPlan = buildPlan(operation, queryPlanner);
|
|
3014
|
+
expect(queryPlan).toMatchInlineSnapshot(`
|
|
3015
|
+
QueryPlan {
|
|
3016
|
+
Sequence {
|
|
3017
|
+
Fetch(service: "S1") {
|
|
3018
|
+
{
|
|
3019
|
+
one {
|
|
3020
|
+
__typename
|
|
3021
|
+
two {
|
|
3022
|
+
__typename
|
|
3023
|
+
id
|
|
3024
|
+
}
|
|
3025
|
+
id
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
},
|
|
3029
|
+
Flatten(path: "one.two") {
|
|
3030
|
+
Fetch(service: "S2") {
|
|
3031
|
+
{
|
|
3032
|
+
... on Two {
|
|
3033
|
+
__typename
|
|
3034
|
+
id
|
|
3035
|
+
}
|
|
3036
|
+
} =>
|
|
3037
|
+
{
|
|
3038
|
+
... on Two {
|
|
3039
|
+
external
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
3042
|
+
},
|
|
3043
|
+
},
|
|
3044
|
+
Flatten(path: "one") {
|
|
3045
|
+
Fetch(service: "S1") {
|
|
3046
|
+
{
|
|
3047
|
+
... on One {
|
|
3048
|
+
__typename
|
|
3049
|
+
two {
|
|
3050
|
+
external
|
|
3051
|
+
}
|
|
3052
|
+
id
|
|
3053
|
+
}
|
|
3054
|
+
} =>
|
|
3055
|
+
{
|
|
3056
|
+
... on One {
|
|
3057
|
+
computed
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
},
|
|
3061
|
+
},
|
|
3062
|
+
},
|
|
3063
|
+
}
|
|
3064
|
+
`);
|
|
3065
|
+
const response = await executePlan(queryPlan, operation, undefined, schema, serviceMap);
|
|
3066
|
+
expect(response.errors).toBeUndefined();
|
|
3067
|
+
expect(response.data).toMatchInlineSnapshot(`
|
|
3068
|
+
Object {
|
|
3069
|
+
"one": Object {
|
|
3070
|
+
"computed": "computed value: v2",
|
|
3071
|
+
},
|
|
3072
|
+
}
|
|
3073
|
+
`);
|
|
3074
|
+
});
|
|
2939
3075
|
});
|
|
2940
3076
|
|
|
2941
3077
|
describe('@key', () => {
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
GraphQLResolverMap,
|
|
4
4
|
GraphQLSchemaValidationError,
|
|
5
5
|
} from '@apollo/subgraph/src/schema-helper';
|
|
6
|
-
import { GraphQLRequest, GraphQLExecutionResult } from 'apollo-server-types';
|
|
7
6
|
import type { Logger } from '@apollo/utils.logger';
|
|
8
7
|
import { buildSubgraphSchema } from '@apollo/subgraph';
|
|
9
8
|
import {
|
|
@@ -19,6 +18,7 @@ import gql from 'graphql-tag';
|
|
|
19
18
|
import { fixtures } from 'apollo-federation-integration-testsuite';
|
|
20
19
|
import { composeServices } from '@apollo/composition';
|
|
21
20
|
import { buildSchema, operationFromDocument, ServiceDefinition } from '@apollo/federation-internals';
|
|
21
|
+
import { GatewayExecutionResult, GatewayGraphQLRequest } from '@apollo/server-gateway-interface';
|
|
22
22
|
|
|
23
23
|
const prettyFormat = require('pretty-format');
|
|
24
24
|
|
|
@@ -36,10 +36,10 @@ export function overrideResolversInService(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export async function execute(
|
|
39
|
-
request:
|
|
39
|
+
request: GatewayGraphQLRequest,
|
|
40
40
|
services: ServiceDefinitionModule[] = fixtures,
|
|
41
41
|
logger: Logger = console,
|
|
42
|
-
): Promise<
|
|
42
|
+
): Promise<GatewayExecutionResult & { queryPlan: QueryPlan }> {
|
|
43
43
|
const serviceMap = Object.fromEntries(
|
|
44
44
|
services.map(({ name, typeDefs, resolvers }) => {
|
|
45
45
|
return [
|
|
@@ -49,7 +49,7 @@ describe('ApolloGateway executor', () => {
|
|
|
49
49
|
variables: { first: '3' },
|
|
50
50
|
},
|
|
51
51
|
queryHash: 'hashed',
|
|
52
|
-
context:
|
|
52
|
+
context: {},
|
|
53
53
|
cache: {} as any,
|
|
54
54
|
logger,
|
|
55
55
|
});
|
|
@@ -85,7 +85,7 @@ describe('ApolloGateway executor', () => {
|
|
|
85
85
|
document: gql(source),
|
|
86
86
|
request: {},
|
|
87
87
|
queryHash: 'hashed',
|
|
88
|
-
context:
|
|
88
|
+
context: {},
|
|
89
89
|
cache: {} as any,
|
|
90
90
|
logger,
|
|
91
91
|
});
|
|
@@ -147,7 +147,7 @@ describe('lifecycle hooks', () => {
|
|
|
147
147
|
// the supergraph (even just formatting differences), this ID will change
|
|
148
148
|
// and this test will have to updated.
|
|
149
149
|
expect(secondCall[0]!.compositionId).toEqual(
|
|
150
|
-
'
|
|
150
|
+
'cc95112b64179c4e549de788b051f44010a02877f568649a42caeeee6a135601',
|
|
151
151
|
);
|
|
152
152
|
// second call should have previous info in the second arg
|
|
153
153
|
expect(secondCall[1]!.compositionId).toEqual(expectedFirstId);
|
|
@@ -4,6 +4,7 @@ import fetcher from 'make-fetch-happen';
|
|
|
4
4
|
import { ApolloGateway, UplinkSupergraphManager } from '@apollo/gateway';
|
|
5
5
|
import { ApolloServer } from 'apollo-server';
|
|
6
6
|
import { ApolloServerPluginUsageReportingDisabled } from 'apollo-server-core';
|
|
7
|
+
import type { FetcherRequestInit } from '@apollo/utils.fetcher';
|
|
7
8
|
|
|
8
9
|
import { nockAfterEach, nockBeforeEach } from '../nockAssertions';
|
|
9
10
|
import {
|
|
@@ -117,9 +118,9 @@ describe('minimal gateway', () => {
|
|
|
117
118
|
let calls = 0;
|
|
118
119
|
gateway = new ApolloGateway({
|
|
119
120
|
logger,
|
|
120
|
-
fetcher: (
|
|
121
|
+
fetcher: (url: string, init?: FetcherRequestInit) => {
|
|
121
122
|
calls++;
|
|
122
|
-
return fetcher(
|
|
123
|
+
return fetcher(url, init);
|
|
123
124
|
},
|
|
124
125
|
});
|
|
125
126
|
server = new ApolloServer({
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLError, GraphQLSchema } from 'graphql';
|
|
2
2
|
import type { HeadersInit } from 'node-fetch';
|
|
3
|
-
import {
|
|
3
|
+
import { GatewayGraphQLRequestContext } from '@apollo/server-gateway-interface';
|
|
4
4
|
import type { Logger } from '@apollo/utils.logger';
|
|
5
5
|
import { GraphQLDataSource } from './datasources/types';
|
|
6
6
|
import { QueryPlan, QueryPlannerConfig } from '@apollo/query-planner';
|
|
@@ -21,9 +21,7 @@ export type Experimental_DidResolveQueryPlanCallback = ({
|
|
|
21
21
|
readonly queryPlan: QueryPlan;
|
|
22
22
|
readonly serviceMap: ServiceMap;
|
|
23
23
|
readonly operationContext: OperationContext;
|
|
24
|
-
readonly requestContext:
|
|
25
|
-
Record<string, any>
|
|
26
|
-
>;
|
|
24
|
+
readonly requestContext: GatewayGraphQLRequestContext;
|
|
27
25
|
}) => void;
|
|
28
26
|
|
|
29
27
|
interface ImplementingServiceLocation {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GatewayGraphQLResponse } from '@apollo/server-gateway-interface';
|
|
2
2
|
import {
|
|
3
3
|
GraphQLSchema,
|
|
4
4
|
graphql,
|
|
@@ -18,7 +18,7 @@ export class LocalGraphQLDataSource<
|
|
|
18
18
|
async process({
|
|
19
19
|
request,
|
|
20
20
|
context,
|
|
21
|
-
}: GraphQLDataSourceProcessOptions<TContext>): Promise<
|
|
21
|
+
}: GraphQLDataSourceProcessOptions<TContext>): Promise<GatewayGraphQLResponse> {
|
|
22
22
|
return graphql({
|
|
23
23
|
schema: this.schema,
|
|
24
24
|
source: request.query!,
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GraphQLRequestContext,
|
|
3
|
-
GraphQLResponse,
|
|
4
|
-
ValueOrPromise,
|
|
5
|
-
GraphQLRequest,
|
|
6
|
-
CacheHint,
|
|
7
|
-
CacheScope,
|
|
8
|
-
CachePolicy,
|
|
9
|
-
} from 'apollo-server-types';
|
|
10
1
|
import { isObject } from '../utilities/predicates';
|
|
11
2
|
import { GraphQLDataSource, GraphQLDataSourceProcessOptions, GraphQLDataSourceRequestKind } from './types';
|
|
12
3
|
import { createHash } from '@apollo/utils.createhash';
|
|
@@ -15,6 +6,7 @@ import fetcher from 'make-fetch-happen';
|
|
|
15
6
|
import { Headers as NodeFetchHeaders, Request as NodeFetchRequest } from 'node-fetch';
|
|
16
7
|
import { Fetcher, FetcherRequestInit, FetcherResponse } from '@apollo/utils.fetcher';
|
|
17
8
|
import { GraphQLError, GraphQLErrorExtensions } from 'graphql';
|
|
9
|
+
import { GatewayCacheHint, GatewayCachePolicy, GatewayGraphQLRequest, GatewayGraphQLRequestContext, GatewayGraphQLResponse } from '@apollo/server-gateway-interface';
|
|
18
10
|
|
|
19
11
|
export class RemoteGraphQLDataSource<
|
|
20
12
|
TContext extends Record<string, any> = Record<string, any>,
|
|
@@ -73,7 +65,7 @@ export class RemoteGraphQLDataSource<
|
|
|
73
65
|
|
|
74
66
|
async process(
|
|
75
67
|
options: GraphQLDataSourceProcessOptions<TContext>,
|
|
76
|
-
): Promise<
|
|
68
|
+
): Promise<GatewayGraphQLResponse> {
|
|
77
69
|
const { request, context: originalContext } = options;
|
|
78
70
|
// Deal with a bit of a hairy situation in typings: when doing health checks
|
|
79
71
|
// and schema checks we always pass in `{}` as the context even though it's
|
|
@@ -114,7 +106,9 @@ export class RemoteGraphQLDataSource<
|
|
|
114
106
|
// there.
|
|
115
107
|
const overallCachePolicy =
|
|
116
108
|
this.honorSubgraphCacheControlHeader &&
|
|
117
|
-
options.kind === GraphQLDataSourceRequestKind.INCOMING_OPERATION
|
|
109
|
+
options.kind === GraphQLDataSourceRequestKind.INCOMING_OPERATION &&
|
|
110
|
+
options.incomingRequestContext.overallCachePolicy &&
|
|
111
|
+
'restrict' in options.incomingRequestContext.overallCachePolicy
|
|
118
112
|
? options.incomingRequestContext.overallCachePolicy
|
|
119
113
|
: null;
|
|
120
114
|
|
|
@@ -156,7 +150,7 @@ export class RemoteGraphQLDataSource<
|
|
|
156
150
|
// If APQ was enabled, we'll run the same request again, but add in the
|
|
157
151
|
// previously omitted `query`. If APQ was NOT enabled, this is the first
|
|
158
152
|
// request (non-APQ, all the way).
|
|
159
|
-
const requestWithQuery:
|
|
153
|
+
const requestWithQuery: GatewayGraphQLRequest = {
|
|
160
154
|
query,
|
|
161
155
|
...requestWithoutQuery,
|
|
162
156
|
};
|
|
@@ -170,9 +164,9 @@ export class RemoteGraphQLDataSource<
|
|
|
170
164
|
}
|
|
171
165
|
|
|
172
166
|
private async sendRequest(
|
|
173
|
-
request:
|
|
167
|
+
request: GatewayGraphQLRequest,
|
|
174
168
|
context: TContext,
|
|
175
|
-
): Promise<
|
|
169
|
+
): Promise<GatewayGraphQLResponse> {
|
|
176
170
|
// This would represent an internal programming error since this shouldn't
|
|
177
171
|
// be possible in the way that this method is invoked right now.
|
|
178
172
|
if (!request.http) {
|
|
@@ -225,7 +219,7 @@ export class RemoteGraphQLDataSource<
|
|
|
225
219
|
|
|
226
220
|
public willSendRequest?(
|
|
227
221
|
options: GraphQLDataSourceProcessOptions<TContext>,
|
|
228
|
-
):
|
|
222
|
+
): void | Promise<void>;
|
|
229
223
|
|
|
230
224
|
private async respond({
|
|
231
225
|
response,
|
|
@@ -233,11 +227,11 @@ export class RemoteGraphQLDataSource<
|
|
|
233
227
|
context,
|
|
234
228
|
overallCachePolicy,
|
|
235
229
|
}: {
|
|
236
|
-
response:
|
|
237
|
-
request:
|
|
230
|
+
response: GatewayGraphQLResponse;
|
|
231
|
+
request: GatewayGraphQLRequest;
|
|
238
232
|
context: TContext;
|
|
239
|
-
overallCachePolicy:
|
|
240
|
-
}): Promise<
|
|
233
|
+
overallCachePolicy: GatewayCachePolicy | null;
|
|
234
|
+
}): Promise<GatewayGraphQLResponse> {
|
|
241
235
|
const processedResponse =
|
|
242
236
|
typeof this.didReceiveResponse === 'function'
|
|
243
237
|
? await this.didReceiveResponse({ response, request, context })
|
|
@@ -252,16 +246,16 @@ export class RemoteGraphQLDataSource<
|
|
|
252
246
|
// thus the overall response) is uncacheable. (If you don't like this, you
|
|
253
247
|
// can tweak the `cache-control` header in your `didReceiveResponse`
|
|
254
248
|
// method.)
|
|
255
|
-
const hint:
|
|
249
|
+
const hint: GatewayCacheHint = { maxAge: 0 };
|
|
256
250
|
const maxAge = parsed['max-age'];
|
|
257
251
|
if (typeof maxAge === 'string' && maxAge.match(/^[0-9]+$/)) {
|
|
258
252
|
hint.maxAge = +maxAge;
|
|
259
253
|
}
|
|
260
254
|
if (parsed['private'] === true) {
|
|
261
|
-
hint.scope =
|
|
255
|
+
hint.scope = 'PRIVATE';
|
|
262
256
|
}
|
|
263
257
|
if (parsed['public'] === true) {
|
|
264
|
-
hint.scope =
|
|
258
|
+
hint.scope = 'PUBLIC';
|
|
265
259
|
}
|
|
266
260
|
overallCachePolicy.restrict(hint);
|
|
267
261
|
}
|
|
@@ -271,9 +265,9 @@ export class RemoteGraphQLDataSource<
|
|
|
271
265
|
|
|
272
266
|
public didReceiveResponse?(
|
|
273
267
|
requestContext: Required<
|
|
274
|
-
Pick<
|
|
268
|
+
Pick<GatewayGraphQLRequestContext<TContext>, 'request' | 'response' | 'context'>
|
|
275
269
|
>,
|
|
276
|
-
):
|
|
270
|
+
): GatewayGraphQLResponse | Promise<GatewayGraphQLResponse>;
|
|
277
271
|
|
|
278
272
|
public didEncounterError(
|
|
279
273
|
error: Error,
|
|
@@ -2,8 +2,8 @@ import { LocalGraphQLDataSource } from '../LocalGraphQLDataSource';
|
|
|
2
2
|
import { buildSubgraphSchema } from '@apollo/subgraph';
|
|
3
3
|
import gql from 'graphql-tag';
|
|
4
4
|
import { GraphQLResolverMap } from '@apollo/subgraph/src/schema-helper';
|
|
5
|
-
import { GraphQLRequestContext } from 'apollo-server-types';
|
|
6
5
|
import { GraphQLDataSourceRequestKind } from '../types';
|
|
6
|
+
import { GatewayGraphQLRequestContext } from '@apollo/server-gateway-interface';
|
|
7
7
|
|
|
8
8
|
describe('constructing requests', () => {
|
|
9
9
|
it('accepts context', async () => {
|
|
@@ -42,7 +42,7 @@ describe('constructing requests', () => {
|
|
|
42
42
|
},
|
|
43
43
|
incomingRequestContext: {
|
|
44
44
|
context: { userId: 2 },
|
|
45
|
-
} as
|
|
45
|
+
} as GatewayGraphQLRequestContext<{userId: number}>,
|
|
46
46
|
context: { userId: 2 },
|
|
47
47
|
});
|
|
48
48
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RemoteGraphQLDataSource } from '../RemoteGraphQLDataSource';
|
|
2
2
|
import { Response, Headers } from 'node-fetch';
|
|
3
|
-
import { GraphQLRequestContext } from 'apollo-server-types';
|
|
4
3
|
import { GraphQLDataSourceRequestKind } from '../types';
|
|
5
4
|
import { nockBeforeEach, nockAfterEach } from '../../__tests__/nockAssertions';
|
|
6
5
|
import nock from 'nock';
|
|
7
6
|
import { GraphQLError } from 'graphql';
|
|
7
|
+
import { GatewayGraphQLRequestContext } from '@apollo/server-gateway-interface';
|
|
8
8
|
|
|
9
9
|
beforeEach(nockBeforeEach);
|
|
10
10
|
afterEach(nockAfterEach);
|
|
@@ -317,7 +317,7 @@ describe('didReceiveResponse', () => {
|
|
|
317
317
|
response,
|
|
318
318
|
}: Required<
|
|
319
319
|
Pick<
|
|
320
|
-
|
|
320
|
+
GatewayGraphQLRequestContext<MyContext>,
|
|
321
321
|
'request' | 'response' | 'context'
|
|
322
322
|
>
|
|
323
323
|
>) {
|
|
@@ -362,7 +362,7 @@ describe('didReceiveResponse', () => {
|
|
|
362
362
|
response,
|
|
363
363
|
}: Required<
|
|
364
364
|
Pick<
|
|
365
|
-
|
|
365
|
+
GatewayGraphQLRequestContext<MyContext>,
|
|
366
366
|
'request' | 'response' | 'context'
|
|
367
367
|
>
|
|
368
368
|
>) {
|
|
@@ -398,7 +398,7 @@ describe('didReceiveResponse', () => {
|
|
|
398
398
|
response,
|
|
399
399
|
}: Required<
|
|
400
400
|
Pick<
|
|
401
|
-
|
|
401
|
+
GatewayGraphQLRequestContext<MyContext>,
|
|
402
402
|
'request' | 'response' | 'context'
|
|
403
403
|
>
|
|
404
404
|
>) {
|
|
@@ -452,7 +452,7 @@ describe('didEncounterError', () => {
|
|
|
452
452
|
},
|
|
453
453
|
incomingRequestContext: {
|
|
454
454
|
context,
|
|
455
|
-
} as
|
|
455
|
+
} as GatewayGraphQLRequestContext<MyContext>,
|
|
456
456
|
context,
|
|
457
457
|
});
|
|
458
458
|
|