@apollo/gateway 2.0.0-preview.1 → 2.0.0-preview.10
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/__generated__/graphqlTypes.d.ts +1 -0
- package/dist/__generated__/graphqlTypes.d.ts.map +1 -1
- package/dist/config.d.ts +9 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/datasources/types.d.ts +1 -1
- package/dist/datasources/types.d.ts.map +1 -1
- package/dist/executeQueryPlan.d.ts +2 -3
- package/dist/executeQueryPlan.d.ts.map +1 -1
- package/dist/executeQueryPlan.js +10 -34
- package/dist/executeQueryPlan.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -50
- package/dist/index.js.map +1 -1
- package/dist/operationContext.js +0 -1
- package/dist/operationContext.js.map +1 -1
- package/dist/schema-helper/resolverMap.d.ts +2 -2
- package/dist/schema-helper/resolverMap.d.ts.map +1 -1
- package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts +1 -1
- package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts.map +1 -1
- package/dist/supergraphManagers/IntrospectAndCompose/index.js +3 -3
- package/dist/supergraphManagers/IntrospectAndCompose/index.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/LegacyFetcher/index.d.ts +1 -1
- package/dist/supergraphManagers/LegacyFetcher/index.d.ts.map +1 -1
- package/dist/supergraphManagers/LegacyFetcher/index.js +3 -3
- package/dist/supergraphManagers/LegacyFetcher/index.js.map +1 -1
- package/dist/supergraphManagers/LocalCompose/index.d.ts +2 -2
- package/dist/supergraphManagers/LocalCompose/index.d.ts.map +1 -1
- package/dist/supergraphManagers/LocalCompose/index.js +4 -4
- package/dist/supergraphManagers/LocalCompose/index.js.map +1 -1
- package/dist/supergraphManagers/UplinkFetcher/index.d.ts +4 -2
- package/dist/supergraphManagers/UplinkFetcher/index.d.ts.map +1 -1
- package/dist/supergraphManagers/UplinkFetcher/index.js +20 -4
- package/dist/supergraphManagers/UplinkFetcher/index.js.map +1 -1
- package/dist/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.d.ts +3 -2
- package/dist/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.d.ts.map +1 -1
- package/dist/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.js +9 -3
- package/dist/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.js.map +1 -1
- package/dist/utilities/array.js +1 -1
- package/dist/utilities/array.js.map +1 -1
- package/package.json +6 -6
- package/src/__generated__/graphqlTypes.ts +1 -1
- package/src/__tests__/buildQueryPlan.test.ts +51 -4
- package/src/__tests__/execution-utils.ts +3 -2
- package/src/__tests__/gateway/executor.test.ts +1 -1
- package/src/__tests__/gateway/lifecycle-hooks.test.ts +5 -5
- package/src/__tests__/gateway/reporting.test.ts +5 -0
- package/src/__tests__/gateway/supergraphSdl.test.ts +1 -1
- package/src/__tests__/integration/complex-key.test.ts +1 -6
- package/src/__tests__/integration/configuration.test.ts +1 -12
- package/src/__tests__/integration/logger.test.ts +1 -1
- package/src/__tests__/integration/networkRequests.test.ts +1 -1
- package/src/config.ts +13 -10
- package/src/core/__tests__/core.test.ts +8 -8
- package/src/index.ts +13 -7
- package/src/supergraphManagers/IntrospectAndCompose/__tests__/IntrospectAndCompose.test.ts +1 -1
- package/src/supergraphManagers/IntrospectAndCompose/index.ts +1 -1
- package/src/supergraphManagers/LegacyFetcher/index.ts +1 -1
- package/src/supergraphManagers/LocalCompose/index.ts +1 -1
- package/src/supergraphManagers/UplinkFetcher/__tests__/loadSupergraphSdlFromStorage.test.ts +41 -0
- package/src/supergraphManagers/UplinkFetcher/index.ts +38 -19
- package/src/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.ts +9 -1
- package/dist/core/index.d.ts +0 -13
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -43
- package/dist/core/index.js.map +0 -1
|
@@ -12,6 +12,8 @@ class UplinkFetcher {
|
|
|
12
12
|
this.timerRef = null;
|
|
13
13
|
this.errorReportingEndpoint = (_a = process.env.APOLLO_OUT_OF_BAND_REPORTER_ENDPOINT) !== null && _a !== void 0 ? _a : undefined;
|
|
14
14
|
this.fetchCount = 0;
|
|
15
|
+
this.minDelayMs = null;
|
|
16
|
+
this.earliestFetchTime = null;
|
|
15
17
|
this.config = options;
|
|
16
18
|
this.state = { phase: 'initialized' };
|
|
17
19
|
}
|
|
@@ -22,7 +24,12 @@ class UplinkFetcher {
|
|
|
22
24
|
}
|
|
23
25
|
let initialSupergraphSdl = null;
|
|
24
26
|
try {
|
|
25
|
-
|
|
27
|
+
const result = await this.updateSupergraphSdl();
|
|
28
|
+
initialSupergraphSdl = (result === null || result === void 0 ? void 0 : result.supergraphSdl) || null;
|
|
29
|
+
if (result === null || result === void 0 ? void 0 : result.minDelaySeconds) {
|
|
30
|
+
this.minDelayMs = 1000 * (result === null || result === void 0 ? void 0 : result.minDelaySeconds);
|
|
31
|
+
this.earliestFetchTime = new Date(Date.now() + this.minDelayMs);
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
34
|
catch (e) {
|
|
28
35
|
this.logUpdateFailure(e);
|
|
@@ -54,6 +61,7 @@ class UplinkFetcher {
|
|
|
54
61
|
compositionId: (_a = this.compositionId) !== null && _a !== void 0 ? _a : null,
|
|
55
62
|
maxRetries: this.config.maxRetries,
|
|
56
63
|
roundRobinSeed: this.fetchCount++,
|
|
64
|
+
earliestFetchTime: this.earliestFetchTime,
|
|
57
65
|
});
|
|
58
66
|
if (!result) {
|
|
59
67
|
return null;
|
|
@@ -61,7 +69,8 @@ class UplinkFetcher {
|
|
|
61
69
|
else {
|
|
62
70
|
this.compositionId = result.id;
|
|
63
71
|
await ((_b = this.healthCheck) === null || _b === void 0 ? void 0 : _b.call(this, result.supergraphSdl));
|
|
64
|
-
|
|
72
|
+
const { supergraphSdl, minDelaySeconds } = result;
|
|
73
|
+
return { supergraphSdl, minDelaySeconds };
|
|
65
74
|
}
|
|
66
75
|
}
|
|
67
76
|
beginPolling() {
|
|
@@ -75,7 +84,12 @@ class UplinkFetcher {
|
|
|
75
84
|
const pollingPromise = (0, resolvable_1.default)();
|
|
76
85
|
this.state.pollingPromise = pollingPromise;
|
|
77
86
|
try {
|
|
78
|
-
const
|
|
87
|
+
const result = await this.updateSupergraphSdl();
|
|
88
|
+
const maybeNewSupergraphSdl = (result === null || result === void 0 ? void 0 : result.supergraphSdl) || null;
|
|
89
|
+
if (result === null || result === void 0 ? void 0 : result.minDelaySeconds) {
|
|
90
|
+
this.minDelayMs = 1000 * (result === null || result === void 0 ? void 0 : result.minDelaySeconds);
|
|
91
|
+
this.earliestFetchTime = new Date(Date.now() + this.minDelayMs);
|
|
92
|
+
}
|
|
79
93
|
if (maybeNewSupergraphSdl) {
|
|
80
94
|
(_a = this.update) === null || _a === void 0 ? void 0 : _a.call(this, maybeNewSupergraphSdl);
|
|
81
95
|
}
|
|
@@ -86,7 +100,9 @@ class UplinkFetcher {
|
|
|
86
100
|
pollingPromise.resolve();
|
|
87
101
|
}
|
|
88
102
|
this.poll();
|
|
89
|
-
}, this.
|
|
103
|
+
}, this.minDelayMs
|
|
104
|
+
? Math.max(this.minDelayMs, this.config.fallbackPollIntervalInMs)
|
|
105
|
+
: this.config.fallbackPollIntervalInMs);
|
|
90
106
|
}
|
|
91
107
|
logUpdateFailure(e) {
|
|
92
108
|
var _a, _b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkFetcher/index.ts"],"names":[],"mappings":";;;;;;AAEA,qEAA6C;AAG7C,iFAA8E;AAkB9E,MAAa,aAAa;
|
|
1
|
+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EACD,IAAI,CAAC,UAAU;YACb,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC;YACjE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CACzC,CAAC;IACJ,CAAC;IAEO,gBAAgB,CAAC,CAAM;;QAC7B,MAAA,IAAI,CAAC,MAAM,CAAC,MAAM,0CAAE,KAAK,CACvB,sEAAsE;YACpE,CAAC,MAAA,CAAC,CAAC,OAAO,mCAAI,CAAC,CAAC,CACnB,CAAC;IACJ,CAAC;CACF;AA7HD,sCA6HC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { fetch } from 'apollo-server-env';
|
|
2
2
|
import { SupergraphSdlUpdate } from '../../config';
|
|
3
|
-
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 }\n ... on FetchError {\n code\n message\n }\n }\n }\n";
|
|
3
|
+
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";
|
|
4
4
|
export declare class UplinkFetcherError extends Error {
|
|
5
5
|
constructor(message: string);
|
|
6
6
|
}
|
|
7
|
-
export declare function loadSupergraphSdlFromUplinks({ graphRef, apiKey, endpoints, errorReportingEndpoint, fetcher, compositionId, maxRetries, roundRobinSeed, }: {
|
|
7
|
+
export declare function loadSupergraphSdlFromUplinks({ graphRef, apiKey, endpoints, errorReportingEndpoint, fetcher, compositionId, maxRetries, roundRobinSeed, earliestFetchTime, }: {
|
|
8
8
|
graphRef: string;
|
|
9
9
|
apiKey: string;
|
|
10
10
|
endpoints: string[];
|
|
@@ -13,6 +13,7 @@ export declare function loadSupergraphSdlFromUplinks({ graphRef, apiKey, endpoin
|
|
|
13
13
|
compositionId: string | null;
|
|
14
14
|
maxRetries: number;
|
|
15
15
|
roundRobinSeed: number;
|
|
16
|
+
earliestFetchTime: Date | null;
|
|
16
17
|
}): Promise<SupergraphSdlUpdate | null>;
|
|
17
18
|
export declare function loadSupergraphSdlFromStorage({ graphRef, apiKey, endpoint, errorReportingEndpoint, fetcher, compositionId, }: {
|
|
18
19
|
graphRef: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadSupergraphSdlFromStorage.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAKnD,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"loadSupergraphSdlFromStorage.d.ts","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAKnD,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,cAAc,EACd,iBAAiB,GAClB,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,KAAK,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAA;CAC/B,GAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAuBvC;AAED,wBAAsB,4BAA4B,CAAC,EACjD,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,sBAAsB,EACtB,OAAO,EACP,aAAa,GACd,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,KAAK,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,GAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAyFvC"}
|
|
@@ -14,6 +14,7 @@ exports.SUPERGRAPH_SDL_QUERY = `#graphql
|
|
|
14
14
|
... on RouterConfigResult {
|
|
15
15
|
id
|
|
16
16
|
supergraphSdl: supergraphSDL
|
|
17
|
+
minDelaySeconds
|
|
17
18
|
}
|
|
18
19
|
... on FetchError {
|
|
19
20
|
code
|
|
@@ -31,7 +32,7 @@ class UplinkFetcherError extends Error {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
exports.UplinkFetcherError = UplinkFetcherError;
|
|
34
|
-
async function loadSupergraphSdlFromUplinks({ graphRef, apiKey, endpoints, errorReportingEndpoint, fetcher, compositionId, maxRetries, roundRobinSeed, }) {
|
|
35
|
+
async function loadSupergraphSdlFromUplinks({ graphRef, apiKey, endpoints, errorReportingEndpoint, fetcher, compositionId, maxRetries, roundRobinSeed, earliestFetchTime, }) {
|
|
35
36
|
return (0, async_retry_1.default)(() => loadSupergraphSdlFromStorage({
|
|
36
37
|
graphRef,
|
|
37
38
|
apiKey,
|
|
@@ -41,6 +42,11 @@ async function loadSupergraphSdlFromUplinks({ graphRef, apiKey, endpoints, error
|
|
|
41
42
|
compositionId,
|
|
42
43
|
}), {
|
|
43
44
|
retries: maxRetries,
|
|
45
|
+
onRetry: async () => {
|
|
46
|
+
const delayMS = earliestFetchTime ? earliestFetchTime.getTime() - Date.now() : 0;
|
|
47
|
+
if (delayMS > 0)
|
|
48
|
+
await new Promise(resolve => setTimeout(resolve, delayMS));
|
|
49
|
+
}
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
exports.loadSupergraphSdlFromUplinks = loadSupergraphSdlFromUplinks;
|
|
@@ -108,8 +114,8 @@ async function loadSupergraphSdlFromStorage({ graphRef, apiKey, endpoint, errorR
|
|
|
108
114
|
}
|
|
109
115
|
const { routerConfig } = response.data;
|
|
110
116
|
if (routerConfig.__typename === 'RouterConfigResult') {
|
|
111
|
-
const { id, supergraphSdl, } = routerConfig;
|
|
112
|
-
return { id, supergraphSdl: supergraphSdl };
|
|
117
|
+
const { id, supergraphSdl, minDelaySeconds, } = routerConfig;
|
|
118
|
+
return { id, supergraphSdl: supergraphSdl, minDelaySeconds };
|
|
113
119
|
}
|
|
114
120
|
else if (routerConfig.__typename === 'FetchError') {
|
|
115
121
|
const { code, message } = routerConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadSupergraphSdlFromStorage.js","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":";;;;;;AAAA,yDAA6D;AAE7D,8DAAgC;AAEhC,2DAAwE;AAI3D,QAAA,oBAAoB,GAAgB
|
|
1
|
+
{"version":3,"file":"loadSupergraphSdlFromStorage.js","sourceRoot":"","sources":["../../../src/supergraphManagers/UplinkFetcher/loadSuperg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EAAE,CAAC,CAAC;KACrD;SAAM,IAAI,YAAY,CAAC,UAAU,KAAK,WAAW,EAAE;QAClD,OAAO,IAAI,CAAC;KACb;SAAM;QACL,MAAM,IAAI,kBAAkB,CAAC,+CAA+C,CAAC,CAAC;KAC/E;AACH,CAAC;AAvGD,oEAuGC"}
|
package/dist/utilities/array.js
CHANGED
|
@@ -19,7 +19,7 @@ function findAndExtract(array, predicate) {
|
|
|
19
19
|
const index = array.findIndex(predicate);
|
|
20
20
|
if (index === -1)
|
|
21
21
|
return [undefined, array];
|
|
22
|
-
|
|
22
|
+
const remaining = array.slice(0, index);
|
|
23
23
|
if (index < array.length - 1) {
|
|
24
24
|
remaining.push(...array.slice(index + 1));
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/utilities/array.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,KAA2B;IAE3B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC;AACxD,CAAC;AAJD,oDAIC;AAED,SAAgB,UAAU,CACxB,KAAU,EACV,UAAyE;IAEzE,OAAO,KAAK,CAAC,MAAM,CACjB,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACjD,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE;YAChC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC1B;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,EACD,EAAS,CACV,CAAC;AACJ,CAAC;AAdD,gCAcC;AAED,SAAgB,cAAc,CAC5B,KAAU,EACV,SAA6D;IAE7D,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,CAAC,CAAC;QAA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AAC,QAAqB,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;YACjC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAE9B,IAAI,KAAK,EAAE;gBACT,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACrB;iBAAM;gBACL,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;aAC5B;SACF;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAjBD,0BAiBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/gateway",
|
|
3
|
-
"version": "2.0.0-preview.
|
|
3
|
+
"version": "2.0.0-preview.10",
|
|
4
4
|
"description": "Apollo Gateway",
|
|
5
5
|
"author": "Apollo <packages@apollographql.com>",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,16 +18,17 @@
|
|
|
18
18
|
"apollo"
|
|
19
19
|
],
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=12.13.0 <
|
|
21
|
+
"node": ">=12.13.0 <18.0"
|
|
22
22
|
},
|
|
23
23
|
"license": "SEE LICENSE IN ./LICENSE",
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@apollo/composition": "^2.0.0-preview.
|
|
28
|
+
"@apollo/composition": "^2.0.0-preview.10",
|
|
29
29
|
"@apollo/core-schema": "^0.2.2",
|
|
30
|
-
"@apollo/query-planner": "^2.0.0-preview.
|
|
30
|
+
"@apollo/query-planner": "^2.0.0-preview.10",
|
|
31
|
+
"@apollo/utils.logger": "^1.0.0",
|
|
31
32
|
"@josephg/resolvable": "^1.0.1",
|
|
32
33
|
"@opentelemetry/api": "^1.0.1",
|
|
33
34
|
"@types/node-fetch": "2.6.1",
|
|
@@ -37,7 +38,6 @@
|
|
|
37
38
|
"apollo-server-env": "^3.0.0 || ^4.0.0",
|
|
38
39
|
"apollo-server-errors": "^2.5.0 || ^3.0.0",
|
|
39
40
|
"apollo-server-types": "^0.9.0 || ^3.0.0",
|
|
40
|
-
"apollo-utilities": "^1.3.0",
|
|
41
41
|
"async-retry": "^1.3.3",
|
|
42
42
|
"loglevel": "^1.6.1",
|
|
43
43
|
"make-fetch-happen": "^8.0.0",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"graphql": "^16.0.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "08b6f94e15020077ff2a88fbf2f000124d307ecd"
|
|
51
51
|
}
|
|
@@ -139,7 +139,7 @@ export type SupergraphSdlQueryVariables = Exact<{
|
|
|
139
139
|
}>;
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
export type SupergraphSdlQuery = { __typename?: 'Query', routerConfig: { __typename: 'FetchError', code: FetchErrorCode, message: string } | { __typename: 'RouterConfigResult', id: string, supergraphSdl: string } | { __typename: 'Unchanged' } };
|
|
142
|
+
export type SupergraphSdlQuery = { __typename?: 'Query', routerConfig: { __typename: 'FetchError', code: FetchErrorCode, message: string } | { __typename: 'RouterConfigResult', id: string, minDelaySeconds: number, supergraphSdl: string } | { __typename: 'Unchanged' } };
|
|
143
143
|
|
|
144
144
|
export type OobReportMutationVariables = Exact<{
|
|
145
145
|
input?: InputMaybe<ApiMonitoringReport>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
astSerializer,
|
|
3
|
+
queryPlanSerializer,
|
|
4
|
+
} from 'apollo-federation-integration-testsuite';
|
|
2
5
|
import { getFederatedTestingSchema } from './execution-utils';
|
|
3
6
|
import { QueryPlan, QueryPlanner } from '@apollo/query-planner';
|
|
4
7
|
import { Schema, parseOperation } from '@apollo/federation-internals';
|
|
@@ -6,14 +9,13 @@ import { Schema, parseOperation } from '@apollo/federation-internals';
|
|
|
6
9
|
expect.addSnapshotSerializer(astSerializer);
|
|
7
10
|
expect.addSnapshotSerializer(queryPlanSerializer);
|
|
8
11
|
|
|
9
|
-
|
|
10
12
|
describe('buildQueryPlan', () => {
|
|
11
13
|
let schema: Schema;
|
|
12
14
|
let queryPlanner: QueryPlanner;
|
|
13
15
|
|
|
14
16
|
const buildPlan = (operation: string): QueryPlan => {
|
|
15
17
|
return queryPlanner.buildQueryPlan(parseOperation(schema, operation));
|
|
16
|
-
}
|
|
18
|
+
};
|
|
17
19
|
|
|
18
20
|
beforeEach(() => {
|
|
19
21
|
expect(
|
|
@@ -515,7 +517,7 @@ describe('buildQueryPlan', () => {
|
|
|
515
517
|
|
|
516
518
|
describe(`when requesting a composite field with subfields from another service`, () => {
|
|
517
519
|
it(`should add key fields to the parent selection set and use a dependent fetch`, () => {
|
|
518
|
-
|
|
520
|
+
const operationString = `#graphql
|
|
519
521
|
query {
|
|
520
522
|
topReviews {
|
|
521
523
|
body
|
|
@@ -1171,4 +1173,49 @@ describe('buildQueryPlan', () => {
|
|
|
1171
1173
|
`);
|
|
1172
1174
|
});
|
|
1173
1175
|
});
|
|
1176
|
+
|
|
1177
|
+
describe('overridden fields and type', () => {
|
|
1178
|
+
it(`query plan of overridden field`, () => {
|
|
1179
|
+
const operationString = `#graphql
|
|
1180
|
+
query {
|
|
1181
|
+
library (id: "3") {
|
|
1182
|
+
name
|
|
1183
|
+
description
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
`;
|
|
1187
|
+
|
|
1188
|
+
const queryPlan = buildPlan(operationString);
|
|
1189
|
+
expect(queryPlan).toMatchInlineSnapshot(`
|
|
1190
|
+
QueryPlan {
|
|
1191
|
+
Sequence {
|
|
1192
|
+
Fetch(service: "books") {
|
|
1193
|
+
{
|
|
1194
|
+
library(id: 3) {
|
|
1195
|
+
__typename
|
|
1196
|
+
id
|
|
1197
|
+
name
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
},
|
|
1201
|
+
Flatten(path: "library") {
|
|
1202
|
+
Fetch(service: "accounts") {
|
|
1203
|
+
{
|
|
1204
|
+
... on Library {
|
|
1205
|
+
__typename
|
|
1206
|
+
id
|
|
1207
|
+
}
|
|
1208
|
+
} =>
|
|
1209
|
+
{
|
|
1210
|
+
... on Library {
|
|
1211
|
+
description
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
},
|
|
1215
|
+
},
|
|
1216
|
+
},
|
|
1217
|
+
}
|
|
1218
|
+
`);
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
1174
1221
|
});
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
GraphQLSchemaModule,
|
|
4
4
|
GraphQLResolverMap,
|
|
5
5
|
} from '../schema-helper';
|
|
6
|
-
import { GraphQLRequest, GraphQLExecutionResult
|
|
6
|
+
import { GraphQLRequest, GraphQLExecutionResult } from 'apollo-server-types';
|
|
7
|
+
import type { Logger } from '@apollo/utils.logger';
|
|
7
8
|
import { buildSubgraphSchema } from '@apollo/subgraph';
|
|
8
9
|
import {
|
|
9
10
|
executeQueryPlan,
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
} from '@apollo/gateway';
|
|
12
13
|
import { QueryPlan, QueryPlanner } from '@apollo/query-planner';
|
|
13
14
|
import { LocalGraphQLDataSource } from '../datasources/LocalGraphQLDataSource';
|
|
14
|
-
import { mergeDeep } from 'apollo
|
|
15
|
+
import { mergeDeep } from '@apollo/client/utilities';
|
|
15
16
|
|
|
16
17
|
import { queryPlanSerializer, astSerializer } from 'apollo-federation-integration-testsuite';
|
|
17
18
|
import gql from 'graphql-tag';
|
|
@@ -2,7 +2,7 @@ import { fetch } from '../../__mocks__/make-fetch-happen-fetcher';
|
|
|
2
2
|
import gql from 'graphql-tag';
|
|
3
3
|
import { ApolloGateway } from '../../';
|
|
4
4
|
import { fixtures } from 'apollo-federation-integration-testsuite';
|
|
5
|
-
import { Logger } from 'apollo
|
|
5
|
+
import type { Logger } from '@apollo/utils.logger';
|
|
6
6
|
|
|
7
7
|
let logger: {
|
|
8
8
|
warn: jest.MockedFunction<Logger['warn']>,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
fixtures,
|
|
17
17
|
fixturesWithUpdate,
|
|
18
18
|
} from 'apollo-federation-integration-testsuite';
|
|
19
|
-
import { Logger } from 'apollo
|
|
19
|
+
import type { Logger } from '@apollo/utils.logger';
|
|
20
20
|
import resolvable from '@josephg/resolvable';
|
|
21
21
|
import { createHash } from '../../utilities/createHash';
|
|
22
22
|
import { getTestingSupergraphSdl } from '../execution-utils';
|
|
@@ -137,7 +137,7 @@ describe('lifecycle hooks', () => {
|
|
|
137
137
|
|
|
138
138
|
const [firstCall, secondCall] = mockDidUpdate.mock.calls;
|
|
139
139
|
|
|
140
|
-
// Note that we've composing our usual test fixtures here
|
|
140
|
+
// Note that we've composing our usual test fixtures here
|
|
141
141
|
const expectedFirstId = createHash('sha256').update(getTestingSupergraphSdl()).digest('hex');
|
|
142
142
|
expect(firstCall[0]!.compositionId).toEqual(expectedFirstId);
|
|
143
143
|
// first call should have no second "previous" argument
|
|
@@ -145,9 +145,9 @@ describe('lifecycle hooks', () => {
|
|
|
145
145
|
|
|
146
146
|
// Note that this assertion is a tad fragile in that every time we modify
|
|
147
147
|
// the supergraph (even just formatting differences), this ID will change
|
|
148
|
-
// and this test will have to updated.
|
|
148
|
+
// and this test will have to updated.
|
|
149
149
|
expect(secondCall[0]!.compositionId).toEqual(
|
|
150
|
-
'
|
|
150
|
+
'730a2fe4036db8e2c847096ba2a62f78ff8f3c08c9ee092a5b1b37e1aa00ef5a',
|
|
151
151
|
);
|
|
152
152
|
// second call should have previous info in the second arg
|
|
153
153
|
expect(secondCall[1]!.compositionId).toEqual(expectedFirstId);
|
|
@@ -183,7 +183,7 @@ describe('lifecycle hooks', () => {
|
|
|
183
183
|
);
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
-
it('registers schema change callbacks when
|
|
186
|
+
it('registers schema change callbacks when pollIntervalInMs is set for unmanaged configs', async () => {
|
|
187
187
|
const experimental_updateServiceDefinitions: Experimental_UpdateServiceDefinitions =
|
|
188
188
|
jest.fn(async (_config) => {
|
|
189
189
|
return { serviceDefinitions, isNewSchema: true };
|
|
@@ -229,6 +229,7 @@ describe('reporting', () => {
|
|
|
229
229
|
"seconds": "1562203363",
|
|
230
230
|
},
|
|
231
231
|
"header": "<HEADER>",
|
|
232
|
+
"operationCount": 1,
|
|
232
233
|
"tracesPerQuery": Object {
|
|
233
234
|
"# -
|
|
234
235
|
{me{name{first last}}topProducts{name}}": Object {
|
|
@@ -301,6 +302,7 @@ describe('reporting', () => {
|
|
|
301
302
|
"nanos": 123000000,
|
|
302
303
|
"seconds": "1562203363",
|
|
303
304
|
},
|
|
305
|
+
"fieldExecutionWeight": 1,
|
|
304
306
|
"root": Object {
|
|
305
307
|
"child": Array [
|
|
306
308
|
Object {
|
|
@@ -366,6 +368,7 @@ describe('reporting', () => {
|
|
|
366
368
|
"nanos": 123000000,
|
|
367
369
|
"seconds": "1562203363",
|
|
368
370
|
},
|
|
371
|
+
"fieldExecutionWeight": 1,
|
|
369
372
|
"root": Object {
|
|
370
373
|
"child": Array [
|
|
371
374
|
Object {
|
|
@@ -467,6 +470,7 @@ describe('reporting', () => {
|
|
|
467
470
|
"nanos": 123000000,
|
|
468
471
|
"seconds": "1562203363",
|
|
469
472
|
},
|
|
473
|
+
"fieldExecutionWeight": 1,
|
|
470
474
|
"root": Object {
|
|
471
475
|
"child": Array [
|
|
472
476
|
Object {
|
|
@@ -556,6 +560,7 @@ describe('reporting', () => {
|
|
|
556
560
|
"nanos": 123000000,
|
|
557
561
|
"seconds": "1562203363",
|
|
558
562
|
},
|
|
563
|
+
"fieldExecutionWeight": 1,
|
|
559
564
|
"root": Object {
|
|
560
565
|
"child": Array [
|
|
561
566
|
Object {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { fixturesWithUpdate } from 'apollo-federation-integration-testsuite';
|
|
8
8
|
import { createHash } from '../../utilities/createHash';
|
|
9
9
|
import { ApolloServer } from 'apollo-server';
|
|
10
|
-
import { Logger } from 'apollo
|
|
10
|
+
import type { Logger } from '@apollo/utils.logger';
|
|
11
11
|
import { fetch } from '../../__mocks__/make-fetch-happen-fetcher';
|
|
12
12
|
import { getTestingSupergraphSdl } from '../execution-utils';
|
|
13
13
|
import { mockAllServicesHealthCheckSuccess } from '../integration/nockMocks';
|
|
@@ -91,12 +91,7 @@ const userService: ServiceDefinitionModule = {
|
|
|
91
91
|
);
|
|
92
92
|
},
|
|
93
93
|
organization(user) {
|
|
94
|
-
return
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
Organization: {
|
|
98
|
-
__resolveObject(object) {
|
|
99
|
-
return organizations.find(org => org.id === object.id);
|
|
94
|
+
return organizations.find(org => org.id === user.organizationId);
|
|
100
95
|
},
|
|
101
96
|
},
|
|
102
97
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import http from 'http';
|
|
3
3
|
import mockedEnv from 'mocked-env';
|
|
4
|
-
import { Logger } from 'apollo
|
|
4
|
+
import type { Logger } from '@apollo/utils.logger';
|
|
5
5
|
import { ApolloGateway } from '../..';
|
|
6
6
|
import {
|
|
7
7
|
mockSdlQuerySuccess,
|
|
@@ -444,15 +444,4 @@ describe('deprecation warnings', () => {
|
|
|
444
444
|
'The `schemaConfigDeliveryEndpoint` option is deprecated and will be removed in a future version of `@apollo/gateway`. Please migrate to the equivalent (array form) `uplinkEndpoints` configuration option.',
|
|
445
445
|
);
|
|
446
446
|
});
|
|
447
|
-
|
|
448
|
-
it('warns with `experimental_pollInterval` option set', async () => {
|
|
449
|
-
new ApolloGateway({
|
|
450
|
-
experimental_pollInterval: 10000,
|
|
451
|
-
logger,
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
expect(logger.warn).toHaveBeenCalledWith(
|
|
455
|
-
'The `experimental_pollInterval` option is deprecated and will be removed in a future version of `@apollo/gateway`. Please migrate to the equivalent `pollIntervalInMs` configuration option.',
|
|
456
|
-
);
|
|
457
|
-
});
|
|
458
447
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { GraphQLObjectType, GraphQLSchema } from 'graphql';
|
|
3
3
|
import mockedEnv from 'mocked-env';
|
|
4
|
-
import { Logger } from 'apollo
|
|
4
|
+
import type { Logger } from '@apollo/utils.logger';
|
|
5
5
|
import { ApolloGateway } from '../..';
|
|
6
6
|
import {
|
|
7
7
|
mockSdlQuerySuccess,
|
package/src/config.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { GraphQLError, GraphQLSchema } from 'graphql';
|
|
2
2
|
import { HeadersInit } from 'node-fetch';
|
|
3
3
|
import { fetch } from 'apollo-server-env';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
Logger,
|
|
7
|
-
} from 'apollo-server-types';
|
|
4
|
+
import { GraphQLRequestContextExecutionDidStart } from 'apollo-server-types';
|
|
5
|
+
import type { Logger } from '@apollo/utils.logger';
|
|
8
6
|
import { GraphQLDataSource } from './datasources/types';
|
|
9
7
|
import { QueryPlan } from '@apollo/query-planner';
|
|
10
8
|
import { OperationContext } from './operationContext';
|
|
@@ -81,6 +79,7 @@ export interface ServiceDefinitionUpdate {
|
|
|
81
79
|
export interface SupergraphSdlUpdate {
|
|
82
80
|
id: string;
|
|
83
81
|
supergraphSdl: string;
|
|
82
|
+
minDelaySeconds?: number;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
export function isSupergraphSdlUpdate(
|
|
@@ -125,11 +124,6 @@ interface GatewayConfigBase {
|
|
|
125
124
|
// experimental observability callbacks
|
|
126
125
|
experimental_didResolveQueryPlan?: Experimental_DidResolveQueryPlanCallback;
|
|
127
126
|
experimental_didUpdateSupergraph?: Experimental_DidUpdateSupergraphCallback;
|
|
128
|
-
/**
|
|
129
|
-
* @deprecated use `pollIntervalInMs` instead
|
|
130
|
-
*/
|
|
131
|
-
experimental_pollInterval?: number;
|
|
132
|
-
pollIntervalInMs?: number;
|
|
133
127
|
experimental_approximateQueryPlanStoreMiB?: number;
|
|
134
128
|
experimental_autoFragmentization?: boolean;
|
|
135
129
|
fetcher?: typeof fetch;
|
|
@@ -150,6 +144,7 @@ export interface ServiceListGatewayConfig extends GatewayConfigBase {
|
|
|
150
144
|
| ((
|
|
151
145
|
service: ServiceEndpointDefinition,
|
|
152
146
|
) => Promise<HeadersInit> | HeadersInit);
|
|
147
|
+
pollIntervalInMs?: number;
|
|
153
148
|
}
|
|
154
149
|
|
|
155
150
|
export interface ManagedGatewayConfig extends GatewayConfigBase {
|
|
@@ -168,6 +163,11 @@ export interface ManagedGatewayConfig extends GatewayConfigBase {
|
|
|
168
163
|
*/
|
|
169
164
|
uplinkEndpoints?: string[];
|
|
170
165
|
uplinkMaxRetries?: number;
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated use `fallbackPollIntervalInMs` instead
|
|
168
|
+
*/
|
|
169
|
+
pollIntervalInMs?: number;
|
|
170
|
+
fallbackPollIntervalInMs?: number;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
// TODO(trevor:removeServiceList): migrate users to `supergraphSdl` function option
|
|
@@ -176,6 +176,7 @@ interface ManuallyManagedServiceDefsGatewayConfig extends GatewayConfigBase {
|
|
|
176
176
|
* @deprecated: use `supergraphSdl` instead (either as a `SupergraphSdlHook` or `SupergraphManager`)
|
|
177
177
|
*/
|
|
178
178
|
experimental_updateServiceDefinitions: Experimental_UpdateServiceDefinitions;
|
|
179
|
+
pollIntervalInMs?: number;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
// TODO(trevor:removeServiceList): migrate users to `supergraphSdl` function option
|
|
@@ -185,6 +186,7 @@ interface ExperimentalManuallyManagedSupergraphSdlGatewayConfig
|
|
|
185
186
|
* @deprecated: use `supergraphSdl` instead (either as a `SupergraphSdlHook` or `SupergraphManager`)
|
|
186
187
|
*/
|
|
187
188
|
experimental_updateSupergraphSdl: Experimental_UpdateSupergraphSdl;
|
|
189
|
+
pollIntervalInMs?: number;
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
export function isManuallyManagedSupergraphSdlGatewayConfig(
|
|
@@ -238,7 +240,7 @@ type ManuallyManagedGatewayConfig =
|
|
|
238
240
|
| ManuallyManagedServiceDefsGatewayConfig
|
|
239
241
|
| ExperimentalManuallyManagedSupergraphSdlGatewayConfig
|
|
240
242
|
| ManuallyManagedSupergraphSdlGatewayConfig
|
|
241
|
-
// TODO(trevor:removeServiceList
|
|
243
|
+
// TODO(trevor:removeServiceList)
|
|
242
244
|
| ServiceListGatewayConfig;
|
|
243
245
|
|
|
244
246
|
// TODO(trevor:removeServiceList)
|
|
@@ -322,6 +324,7 @@ export function isManagedConfig(
|
|
|
322
324
|
return (
|
|
323
325
|
'schemaConfigDeliveryEndpoint' in config ||
|
|
324
326
|
'uplinkEndpoints' in config ||
|
|
327
|
+
'fallbackPollIntervalInMs' in config ||
|
|
325
328
|
(!isLocalConfig(config) &&
|
|
326
329
|
!isStaticSupergraphSdlConfig(config) &&
|
|
327
330
|
!isManuallyManagedConfig(config))
|