@apollo/gateway 0.44.0 → 0.45.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/CHANGELOG.md +14 -3
- package/dist/__generated__/graphqlTypes.d.ts +13 -12
- package/dist/__generated__/graphqlTypes.d.ts.map +1 -1
- package/dist/__generated__/graphqlTypes.js.map +1 -1
- package/dist/config.d.ts +3 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -17
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -37
- package/dist/index.js.map +1 -1
- package/dist/loadSupergraphSdlFromStorage.d.ts +13 -5
- package/dist/loadSupergraphSdlFromStorage.d.ts.map +1 -1
- package/dist/loadSupergraphSdlFromStorage.js +34 -7
- package/dist/loadSupergraphSdlFromStorage.js.map +1 -1
- package/dist/outOfBandReporter.d.ts +10 -12
- package/dist/outOfBandReporter.d.ts.map +1 -1
- package/dist/outOfBandReporter.js +70 -73
- package/dist/outOfBandReporter.js.map +1 -1
- package/package.json +9 -9
- package/src/__generated__/graphqlTypes.ts +13 -12
- package/src/__tests__/gateway/reporting.test.ts +5 -3
- package/src/__tests__/integration/configuration.test.ts +32 -11
- package/src/__tests__/integration/networkRequests.test.ts +22 -22
- package/src/__tests__/integration/nockMocks.ts +12 -6
- package/src/__tests__/loadSupergraphSdlFromStorage.test.ts +101 -377
- package/src/__tests__/nockAssertions.ts +20 -0
- package/src/config.ts +10 -43
- package/src/index.ts +36 -56
- package/src/loadSupergraphSdlFromStorage.ts +54 -8
- package/src/outOfBandReporter.ts +87 -89
- package/dist/legacyLoadServicesFromStorage.d.ts +0 -20
- package/dist/legacyLoadServicesFromStorage.d.ts.map +0 -1
- package/dist/legacyLoadServicesFromStorage.js +0 -62
- package/dist/legacyLoadServicesFromStorage.js.map +0 -1
- package/src/__tests__/integration/legacyNetworkRequests.test.ts +0 -279
- package/src/__tests__/integration/legacyNockMocks.ts +0 -113
- package/src/legacyLoadServicesFromStorage.ts +0 -170
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadSupergraphSdlFromStorage = exports.SUPERGRAPH_SDL_QUERY = void 0;
|
|
3
|
+
exports.loadSupergraphSdlFromStorage = exports.loadSupergraphSdlFromUplinks = exports.SUPERGRAPH_SDL_QUERY = void 0;
|
|
4
4
|
const apollo_server_env_1 = require("apollo-server-env");
|
|
5
5
|
const outOfBandReporter_1 = require("./outOfBandReporter");
|
|
6
6
|
exports.SUPERGRAPH_SDL_QUERY = `#graphql
|
|
@@ -20,7 +20,33 @@ exports.SUPERGRAPH_SDL_QUERY = `#graphql
|
|
|
20
20
|
`;
|
|
21
21
|
const { name, version } = require('../package.json');
|
|
22
22
|
const fetchErrorMsg = "An error occurred while fetching your schema from Apollo: ";
|
|
23
|
-
|
|
23
|
+
let fetchCounter = 0;
|
|
24
|
+
async function loadSupergraphSdlFromUplinks({ graphRef, apiKey, endpoints, errorReportingEndpoint, fetcher, compositionId, maxRetries, }) {
|
|
25
|
+
let retries = 0;
|
|
26
|
+
let lastException = null;
|
|
27
|
+
let result = null;
|
|
28
|
+
while (retries++ <= maxRetries && result == null) {
|
|
29
|
+
try {
|
|
30
|
+
result = await loadSupergraphSdlFromStorage({
|
|
31
|
+
graphRef,
|
|
32
|
+
apiKey,
|
|
33
|
+
endpoint: endpoints[fetchCounter++ % endpoints.length],
|
|
34
|
+
errorReportingEndpoint,
|
|
35
|
+
fetcher,
|
|
36
|
+
compositionId
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
lastException = e;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (result === null && lastException !== null) {
|
|
44
|
+
throw lastException;
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
exports.loadSupergraphSdlFromUplinks = loadSupergraphSdlFromUplinks;
|
|
49
|
+
async function loadSupergraphSdlFromStorage({ graphRef, apiKey, endpoint, errorReportingEndpoint, fetcher, compositionId, }) {
|
|
24
50
|
var _a, _b;
|
|
25
51
|
let result;
|
|
26
52
|
const requestDetails = {
|
|
@@ -41,19 +67,19 @@ async function loadSupergraphSdlFromStorage({ graphRef, apiKey, endpoint, fetche
|
|
|
41
67
|
},
|
|
42
68
|
};
|
|
43
69
|
const request = new apollo_server_env_1.Request(endpoint, requestDetails);
|
|
44
|
-
const OOBReport = new outOfBandReporter_1.OutOfBandReporter();
|
|
45
70
|
const startTime = new Date();
|
|
46
71
|
try {
|
|
47
72
|
result = await fetcher(endpoint, requestDetails);
|
|
48
73
|
}
|
|
49
74
|
catch (e) {
|
|
50
75
|
const endTime = new Date();
|
|
51
|
-
await
|
|
76
|
+
await (0, outOfBandReporter_1.submitOutOfBandReportIfConfigured)({
|
|
52
77
|
error: e,
|
|
53
78
|
request,
|
|
79
|
+
endpoint: errorReportingEndpoint,
|
|
54
80
|
startedAt: startTime,
|
|
55
81
|
endedAt: endTime,
|
|
56
|
-
fetcher
|
|
82
|
+
fetcher,
|
|
57
83
|
});
|
|
58
84
|
throw new Error(fetchErrorMsg + ((_a = e.message) !== null && _a !== void 0 ? _a : e));
|
|
59
85
|
}
|
|
@@ -71,13 +97,14 @@ async function loadSupergraphSdlFromStorage({ graphRef, apiKey, endpoint, fetche
|
|
|
71
97
|
}
|
|
72
98
|
}
|
|
73
99
|
else {
|
|
74
|
-
await
|
|
100
|
+
await (0, outOfBandReporter_1.submitOutOfBandReportIfConfigured)({
|
|
75
101
|
error: new Error(fetchErrorMsg + result.status + ' ' + result.statusText),
|
|
76
102
|
request,
|
|
103
|
+
endpoint: errorReportingEndpoint,
|
|
77
104
|
response: result,
|
|
78
105
|
startedAt: startTime,
|
|
79
106
|
endedAt: endTime,
|
|
80
|
-
fetcher
|
|
107
|
+
fetcher,
|
|
81
108
|
});
|
|
82
109
|
throw new Error(fetchErrorMsg + result.status + ' ' + result.statusText);
|
|
83
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadSupergraphSdlFromStorage.js","sourceRoot":"","sources":["../src/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":";;;AAAA,yDAA6D;
|
|
1
|
+
{"version":3,"file":"loadSupergraphSdlFromStorage.js","sourceRoot":"","sources":["../src/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":";;;AAAA,yDAA6D;AAG7D,2DAAwE;AAI3D,QAAA,oBAAoB,GAAgB;;;;;;;;;;;;;;CAchD,CAAC;AAgBF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAErD,MAAM,aAAa,GAAG,4DAA4D,CAAC;AAEnF,IAAI,YAAY,GAAG,CAAC,CAAC;AAEd,KAAK,UAAU,4BAA4B,CAAC,EACjD,QAAQ,EACR,MAAM,EACN,SAAS,EACT,sBAAsB,EACtB,OAAO,EACP,aAAa,EACb,UAAU,GASX;IACC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,aAAa,GAAG,IAAI,CAAC;IACzB,IAAI,MAAM,GAA+B,IAAI,CAAC;IAC9C,OAAO,OAAO,EAAE,IAAI,UAAU,IAAI,MAAM,IAAI,IAAI,EAAE;QAChD,IAAI;YACF,MAAM,GAAG,MAAM,4BAA4B,CAAC;gBAC1C,QAAQ;gBACR,MAAM;gBACN,QAAQ,EAAE,SAAS,CAAC,YAAY,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC;gBACtD,sBAAsB;gBACtB,OAAO;gBACP,aAAa;aACd,CAAC,CAAC;SACJ;QAAC,OAAO,CAAC,EAAE;YACV,aAAa,GAAG,CAAC,CAAC;SACnB;KACF;IACD,IAAI,MAAM,KAAK,IAAI,IAAI,aAAa,KAAK,IAAI,EAAE;QAC7C,MAAM,aAAa,CAAC;KACrB;IACD,OAAO,MAAM,CAAC;AACh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AM,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;KACxC;SAAM,IAAI,YAAY,CAAC,UAAU,KAAK,WAAW,EAAE;QAClD,OAAO,IAAI,CAAC;KACb;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;AACH,CAAC;AAtGD,oEAsGC"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { fetch, Response, Request } from 'apollo-server-env';
|
|
2
2
|
export declare const OUT_OF_BAND_REPORTER_QUERY = "#graphql\n mutation OOBReport($input: APIMonitoringReport) {\n reportError(report: $input)\n }\n";
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
}
|
|
3
|
+
export declare function submitOutOfBandReportIfConfigured({ error, request, endpoint, response, startedAt, endedAt, tags, fetcher, }: {
|
|
4
|
+
error: Error;
|
|
5
|
+
request: Request;
|
|
6
|
+
endpoint: string | undefined;
|
|
7
|
+
response?: Response;
|
|
8
|
+
startedAt: Date;
|
|
9
|
+
endedAt: Date;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
fetcher: typeof fetch;
|
|
12
|
+
}): Promise<void>;
|
|
15
13
|
//# sourceMappingURL=outOfBandReporter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outOfBandReporter.d.ts","sourceRoot":"","sources":["../src/outOfBandReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAS7D,eAAO,MAAM,0BAA0B,0GAItC,CAAC;
|
|
1
|
+
{"version":3,"file":"outOfBandReporter.d.ts","sourceRoot":"","sources":["../src/outOfBandReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAS7D,eAAO,MAAM,0BAA0B,0GAItC,CAAC;AAiBF,wBAAsB,iCAAiC,CAAC,EACtD,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,GACR,EAAE;IACD,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,KAAK,CAAC;CACvB,iBA6EA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.submitOutOfBandReportIfConfigured = exports.OUT_OF_BAND_REPORTER_QUERY = void 0;
|
|
4
4
|
const graphqlTypes_1 = require("./__generated__/graphqlTypes");
|
|
5
5
|
exports.OUT_OF_BAND_REPORTER_QUERY = `#graphql
|
|
6
6
|
mutation OOBReport($input: APIMonitoringReport) {
|
|
@@ -8,81 +8,78 @@ exports.OUT_OF_BAND_REPORTER_QUERY = `#graphql
|
|
|
8
8
|
}
|
|
9
9
|
`;
|
|
10
10
|
const { name, version } = require('../package.json');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
errorCode = graphqlTypes_1.ErrorCode.Other;
|
|
38
|
-
}
|
|
11
|
+
async function submitOutOfBandReportIfConfigured({ error, request, endpoint, response, startedAt, endedAt, tags, fetcher, }) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
if (!endpoint) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
let errorCode;
|
|
17
|
+
if (!response) {
|
|
18
|
+
errorCode = graphqlTypes_1.ErrorCode.ConnectionFailed;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
switch (response.status) {
|
|
22
|
+
case 400:
|
|
23
|
+
case 413:
|
|
24
|
+
case 422:
|
|
25
|
+
errorCode = graphqlTypes_1.ErrorCode.InvalidBody;
|
|
26
|
+
break;
|
|
27
|
+
case 408:
|
|
28
|
+
case 504:
|
|
29
|
+
errorCode = graphqlTypes_1.ErrorCode.Timeout;
|
|
30
|
+
break;
|
|
31
|
+
case 502:
|
|
32
|
+
case 503:
|
|
33
|
+
errorCode = graphqlTypes_1.ErrorCode.ConnectionFailed;
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
errorCode = graphqlTypes_1.ErrorCode.Other;
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
request: {
|
|
48
|
-
url: request.url,
|
|
49
|
-
body: await request.text(),
|
|
50
|
-
},
|
|
51
|
-
response: response
|
|
52
|
-
? {
|
|
53
|
-
httpStatusCode: response.status,
|
|
54
|
-
body: responseBody,
|
|
55
|
-
}
|
|
56
|
-
: null,
|
|
57
|
-
startedAt: startedAt.toISOString(),
|
|
58
|
-
endedAt: endedAt.toISOString(),
|
|
59
|
-
tags: tags,
|
|
38
|
+
}
|
|
39
|
+
const responseBody = await (response === null || response === void 0 ? void 0 : response.text());
|
|
40
|
+
const variables = {
|
|
41
|
+
input: {
|
|
42
|
+
error: {
|
|
43
|
+
code: errorCode,
|
|
44
|
+
message: error.message,
|
|
60
45
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
46
|
+
request: {
|
|
47
|
+
url: request.url,
|
|
48
|
+
body: await request.text(),
|
|
49
|
+
},
|
|
50
|
+
response: response
|
|
51
|
+
? {
|
|
52
|
+
httpStatusCode: response.status,
|
|
53
|
+
body: responseBody,
|
|
54
|
+
}
|
|
55
|
+
: null,
|
|
56
|
+
startedAt: startedAt.toISOString(),
|
|
57
|
+
endedAt: endedAt.toISOString(),
|
|
58
|
+
tags: tags,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
try {
|
|
62
|
+
const oobResponse = await fetcher(endpoint, {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
body: JSON.stringify({
|
|
65
|
+
query: exports.OUT_OF_BAND_REPORTER_QUERY,
|
|
66
|
+
variables,
|
|
67
|
+
}),
|
|
68
|
+
headers: {
|
|
69
|
+
'apollographql-client-name': name,
|
|
70
|
+
'apollographql-client-version': version,
|
|
71
|
+
'user-agent': `${name}/${version}`,
|
|
72
|
+
'content-type': 'application/json',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
const parsedResponse = await oobResponse.json();
|
|
76
|
+
if (!((_a = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.data) === null || _a === void 0 ? void 0 : _a.reportError)) {
|
|
77
|
+
throw new Error(`Out-of-band error reporting failed: ${oobResponse.status} ${oobResponse.statusText}`);
|
|
83
78
|
}
|
|
84
79
|
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
throw new Error(`Out-of-band error reporting failed: ${(_b = e.message) !== null && _b !== void 0 ? _b : e}`);
|
|
82
|
+
}
|
|
85
83
|
}
|
|
86
|
-
exports.
|
|
87
|
-
OutOfBandReporter.endpoint = process.env.APOLLO_OUT_OF_BAND_REPORTER_ENDPOINT || null;
|
|
84
|
+
exports.submitOutOfBandReportIfConfigured = submitOutOfBandReportIfConfigured;
|
|
88
85
|
//# sourceMappingURL=outOfBandReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outOfBandReporter.js","sourceRoot":"","sources":["../src/outOfBandReporter.ts"],"names":[],"mappings":";;;AAEA,+DAIsC;AAGzB,QAAA,0BAA0B,GAAgB;;;;CAItD,CAAC;AAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"outOfBandReporter.js","sourceRoot":"","sources":["../src/outOfBandReporter.ts"],"names":[],"mappings":";;;AAEA,+DAIsC;AAGzB,QAAA,0BAA0B,GAAgB;;;;CAItD,CAAC;AAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAe9C,KAAK,UAAU,iCAAiC,CAAC,EACtD,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,GAUR;;IAEC,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO;KACR;IAED,IAAI,SAAoB,CAAC;IACzB,IAAI,CAAC,QAAQ,EAAE;QACb,SAAS,GAAG,wBAAS,CAAC,gBAAgB,CAAC;KACxC;SAAM;QAEL,QAAQ,QAAQ,CAAC,MAAM,EAAE;YACvB,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,SAAS,GAAG,wBAAS,CAAC,WAAW,CAAC;gBAClC,MAAM;YACR,KAA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AM,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;AA/FD,8EA+FC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/gateway",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "Apollo Gateway",
|
|
5
5
|
"author": "Apollo <packages@apollographql.com>",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,23 +26,23 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@apollo/core-schema": "^0.2.0",
|
|
29
|
-
"@apollo/federation": "^0.33.
|
|
30
|
-
"@apollo/query-planner": "^0.6.
|
|
29
|
+
"@apollo/federation": "^0.33.8",
|
|
30
|
+
"@apollo/query-planner": "^0.6.3",
|
|
31
31
|
"@opentelemetry/api": "^1.0.1",
|
|
32
32
|
"@types/node-fetch": "2.5.12",
|
|
33
|
-
"apollo-graphql": "^0.9.
|
|
34
|
-
"apollo-reporting-protobuf": "^0.8.0 || ^3.0.0",
|
|
33
|
+
"apollo-graphql": "^0.9.5",
|
|
34
|
+
"apollo-reporting-protobuf": "^0.8.0 || ^3.0.0 || ^3.3.0-alpha.0",
|
|
35
35
|
"apollo-server-caching": "^0.7.0 || ^3.0.0",
|
|
36
|
-
"apollo-server-core": "^2.23.0 || ^3.0.0",
|
|
36
|
+
"apollo-server-core": "^2.23.0 || ^3.0.0 || ^3.6.0-alpha.0",
|
|
37
37
|
"apollo-server-env": "^3.0.0 || ^4.0.0",
|
|
38
38
|
"apollo-server-errors": "^2.5.0 || ^3.0.0",
|
|
39
|
-
"apollo-server-types": "^0.9.0 || ^3.0.0",
|
|
39
|
+
"apollo-server-types": "^0.9.0 || ^3.0.0 || ^3.5.0-alpha.0",
|
|
40
40
|
"loglevel": "^1.6.1",
|
|
41
41
|
"make-fetch-happen": "^8.0.0",
|
|
42
|
-
"pretty-format": "^
|
|
42
|
+
"pretty-format": "^27.3.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"graphql": "^15.7.2"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "6da531f786edaee9cde8e12064bac6934caa13bc"
|
|
48
48
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type Maybe<T> = T | null;
|
|
2
|
+
export type InputMaybe<T> = Maybe<T>;
|
|
2
3
|
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
3
4
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
|
4
5
|
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
|
@@ -17,15 +18,15 @@ export type ApiMonitoringReport = {
|
|
|
17
18
|
endedAt: Scalars['Timestamp'];
|
|
18
19
|
error: Error;
|
|
19
20
|
request: Request;
|
|
20
|
-
response?:
|
|
21
|
+
response?: InputMaybe<Response>;
|
|
21
22
|
startedAt: Scalars['Timestamp'];
|
|
22
23
|
/** Tags can include things like version and package name */
|
|
23
|
-
tags?:
|
|
24
|
+
tags?: InputMaybe<Array<Scalars['String']>>;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export type Error = {
|
|
27
28
|
code: ErrorCode;
|
|
28
|
-
message?:
|
|
29
|
+
message?: InputMaybe<Scalars['String']>;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export enum ErrorCode {
|
|
@@ -55,7 +56,7 @@ export enum FetchErrorCode {
|
|
|
55
56
|
|
|
56
57
|
export type HttpHeader = {
|
|
57
58
|
name: Scalars['String'];
|
|
58
|
-
value?:
|
|
59
|
+
value?: InputMaybe<Scalars['String']>;
|
|
59
60
|
};
|
|
60
61
|
|
|
61
62
|
export type Message = {
|
|
@@ -77,7 +78,7 @@ export type Mutation = {
|
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
export type MutationReportErrorArgs = {
|
|
80
|
-
report?:
|
|
81
|
+
report?: InputMaybe<ApiMonitoringReport>;
|
|
81
82
|
};
|
|
82
83
|
|
|
83
84
|
export type Query = {
|
|
@@ -90,19 +91,19 @@ export type Query = {
|
|
|
90
91
|
|
|
91
92
|
export type QueryRouterConfigArgs = {
|
|
92
93
|
apiKey: Scalars['String'];
|
|
93
|
-
ifAfterId?:
|
|
94
|
+
ifAfterId?: InputMaybe<Scalars['ID']>;
|
|
94
95
|
ref: Scalars['String'];
|
|
95
96
|
};
|
|
96
97
|
|
|
97
98
|
export type Request = {
|
|
98
|
-
body?:
|
|
99
|
-
headers?:
|
|
99
|
+
body?: InputMaybe<Scalars['String']>;
|
|
100
|
+
headers?: InputMaybe<Array<HttpHeader>>;
|
|
100
101
|
url: Scalars['String'];
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
export type Response = {
|
|
104
|
-
body?:
|
|
105
|
-
headers?:
|
|
105
|
+
body?: InputMaybe<Scalars['String']>;
|
|
106
|
+
headers?: InputMaybe<Array<HttpHeader>>;
|
|
106
107
|
httpStatusCode: Scalars['Int'];
|
|
107
108
|
};
|
|
108
109
|
|
|
@@ -125,14 +126,14 @@ export type Unchanged = {
|
|
|
125
126
|
export type SupergraphSdlQueryVariables = Exact<{
|
|
126
127
|
apiKey: Scalars['String'];
|
|
127
128
|
ref: Scalars['String'];
|
|
128
|
-
ifAfterId?:
|
|
129
|
+
ifAfterId?: InputMaybe<Scalars['ID']>;
|
|
129
130
|
}>;
|
|
130
131
|
|
|
131
132
|
|
|
132
133
|
export type SupergraphSdlQuery = { __typename?: 'Query', routerConfig: { __typename: 'FetchError', code: FetchErrorCode, message: string } | { __typename: 'RouterConfigResult', id: string, supergraphSdl: string } | { __typename: 'Unchanged' } };
|
|
133
134
|
|
|
134
135
|
export type OobReportMutationVariables = Exact<{
|
|
135
|
-
input?:
|
|
136
|
+
input?: InputMaybe<ApiMonitoringReport>;
|
|
136
137
|
}>;
|
|
137
138
|
|
|
138
139
|
|
|
@@ -12,6 +12,7 @@ import { ApolloGateway } from '../..';
|
|
|
12
12
|
import { Plugin, Config, Refs } from 'pretty-format';
|
|
13
13
|
import { Report, Trace } from 'apollo-reporting-protobuf';
|
|
14
14
|
import { fixtures } from 'apollo-federation-integration-testsuite';
|
|
15
|
+
import { nockAfterEach, nockBeforeEach } from '../nockAssertions';
|
|
15
16
|
|
|
16
17
|
// Normalize specific fields that change often (eg timestamps) to static values,
|
|
17
18
|
// to make snapshot testing viable. (If these helpers are more generally
|
|
@@ -89,7 +90,6 @@ describe('reporting', () => {
|
|
|
89
90
|
let gatewayServer: ApolloServer;
|
|
90
91
|
let gatewayUrl: string;
|
|
91
92
|
let reportPromise: Promise<any>;
|
|
92
|
-
let nockScope: nock.Scope;
|
|
93
93
|
|
|
94
94
|
beforeEach(async () => {
|
|
95
95
|
let reportResolver: (report: any) => void;
|
|
@@ -97,7 +97,8 @@ describe('reporting', () => {
|
|
|
97
97
|
reportResolver = resolve;
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
nockBeforeEach();
|
|
101
|
+
nock('https://usage-reporting.api.apollographql.com')
|
|
101
102
|
.post('/api/ingress/traces')
|
|
102
103
|
.reply(200, (_: any, requestBody: string) => {
|
|
103
104
|
reportResolver(requestBody);
|
|
@@ -137,7 +138,8 @@ describe('reporting', () => {
|
|
|
137
138
|
if (gatewayServer) {
|
|
138
139
|
await gatewayServer.stop();
|
|
139
140
|
}
|
|
140
|
-
|
|
141
|
+
|
|
142
|
+
nockAfterEach();
|
|
141
143
|
});
|
|
142
144
|
|
|
143
145
|
it(`queries three services`, async () => {
|
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
mockSdlQuerySuccess,
|
|
8
8
|
mockSupergraphSdlRequestSuccess,
|
|
9
9
|
mockApolloConfig,
|
|
10
|
-
|
|
10
|
+
mockCloudConfigUrl1,
|
|
11
|
+
mockCloudConfigUrl2,
|
|
12
|
+
mockCloudConfigUrl3,
|
|
11
13
|
} from './nockMocks';
|
|
12
14
|
import { getTestingSupergraphSdl } from '../execution-utils';
|
|
13
15
|
import { MockService } from './networkRequests.test';
|
|
@@ -110,8 +112,26 @@ describe('gateway configuration warnings', () => {
|
|
|
110
112
|
|
|
111
113
|
gateway = new ApolloGateway({
|
|
112
114
|
logger,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
uplinkEndpoints: [mockCloudConfigUrl1],
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
await gateway.load(mockApolloConfig);
|
|
119
|
+
|
|
120
|
+
await gateway.stop();
|
|
121
|
+
|
|
122
|
+
expect(logger.warn).not.toHaveBeenCalledWith(
|
|
123
|
+
expect.stringMatching(
|
|
124
|
+
/A local gateway configuration is overriding a managed federation configuration/,
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('deprecated conflicting configurations are not warned about when absent', async () => {
|
|
130
|
+
mockSupergraphSdlRequestSuccess();
|
|
131
|
+
|
|
132
|
+
gateway = new ApolloGateway({
|
|
133
|
+
logger,
|
|
134
|
+
schemaConfigDeliveryEndpoint: mockCloudConfigUrl1,
|
|
115
135
|
});
|
|
116
136
|
|
|
117
137
|
await gateway.load(mockApolloConfig);
|
|
@@ -300,7 +320,6 @@ describe('gateway config / env behavior', () => {
|
|
|
300
320
|
});
|
|
301
321
|
});
|
|
302
322
|
|
|
303
|
-
// TODO(trevor:cloudconfig): this behavior will be updated
|
|
304
323
|
describe('schema config delivery endpoint configuration', () => {
|
|
305
324
|
it('A code config overrides the env variable', async () => {
|
|
306
325
|
cleanUp = mockedEnv({
|
|
@@ -309,28 +328,30 @@ describe('gateway config / env behavior', () => {
|
|
|
309
328
|
|
|
310
329
|
gateway = new ApolloGateway({
|
|
311
330
|
logger,
|
|
312
|
-
|
|
331
|
+
uplinkEndpoints: [mockCloudConfigUrl1, mockCloudConfigUrl2, mockCloudConfigUrl3],
|
|
313
332
|
});
|
|
314
333
|
|
|
315
|
-
expect(gateway['
|
|
316
|
-
|
|
334
|
+
expect(gateway['uplinkEndpoints']).toEqual(
|
|
335
|
+
[mockCloudConfigUrl1, mockCloudConfigUrl2, mockCloudConfigUrl3],
|
|
317
336
|
);
|
|
318
337
|
|
|
319
338
|
gateway = null;
|
|
320
339
|
});
|
|
340
|
+
});
|
|
321
341
|
|
|
322
|
-
|
|
342
|
+
describe('deprecated schema config delivery endpoint configuration', () => {
|
|
343
|
+
it('A code config overrides the env variable', async () => {
|
|
323
344
|
cleanUp = mockedEnv({
|
|
324
345
|
APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT: 'env-config',
|
|
325
346
|
});
|
|
326
347
|
|
|
327
348
|
gateway = new ApolloGateway({
|
|
328
349
|
logger,
|
|
329
|
-
schemaConfigDeliveryEndpoint:
|
|
350
|
+
schemaConfigDeliveryEndpoint: 'code-config',
|
|
330
351
|
});
|
|
331
352
|
|
|
332
|
-
expect(gateway['
|
|
333
|
-
|
|
353
|
+
expect(gateway['uplinkEndpoints']).toEqual(
|
|
354
|
+
['code-config'],
|
|
334
355
|
);
|
|
335
356
|
|
|
336
357
|
gateway = null;
|