@apollo/gateway 0.44.1 → 0.45.1
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 +18 -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/executeQueryPlan.d.ts.map +1 -1
- package/dist/executeQueryPlan.js +1 -1
- 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 +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 +7 -7
- package/src/__generated__/graphqlTypes.ts +13 -12
- package/src/__tests__/executeQueryPlan.test.ts +636 -0
- 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/executeQueryPlan.ts +11 -1
- 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,13 +1,21 @@
|
|
|
1
1
|
import { fetch } from 'apollo-server-env';
|
|
2
|
+
import { SupergraphSdlUpdate } from './config';
|
|
2
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 function
|
|
4
|
+
export declare function loadSupergraphSdlFromUplinks({ graphRef, apiKey, endpoints, errorReportingEndpoint, fetcher, compositionId, maxRetries, }: {
|
|
5
|
+
graphRef: string;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
endpoints: string[];
|
|
8
|
+
errorReportingEndpoint: string | undefined;
|
|
9
|
+
fetcher: typeof fetch;
|
|
10
|
+
compositionId: string | null;
|
|
11
|
+
maxRetries: number;
|
|
12
|
+
}): Promise<SupergraphSdlUpdate | null>;
|
|
13
|
+
export declare function loadSupergraphSdlFromStorage({ graphRef, apiKey, endpoint, errorReportingEndpoint, fetcher, compositionId, }: {
|
|
4
14
|
graphRef: string;
|
|
5
15
|
apiKey: string;
|
|
6
16
|
endpoint: string;
|
|
17
|
+
errorReportingEndpoint?: string;
|
|
7
18
|
fetcher: typeof fetch;
|
|
8
19
|
compositionId: string | null;
|
|
9
|
-
}): Promise<
|
|
10
|
-
id: string;
|
|
11
|
-
supergraphSdl: string;
|
|
12
|
-
} | null>;
|
|
20
|
+
}): Promise<SupergraphSdlUpdate | null>;
|
|
13
21
|
//# sourceMappingURL=loadSupergraphSdlFromStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadSupergraphSdlFromStorage.d.ts","sourceRoot":"","sources":["../src/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"loadSupergraphSdlFromStorage.d.ts","sourceRoot":"","sources":["../src/loadSupergraphSdlFromStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAK/C,eAAO,MAAM,oBAAoB,+VAchC,CAAC;AAsBF,wBAAsB,4BAA4B,CAAC,EACjD,QAAQ,EACR,MAAM,EACN,SAAS,EACT,sBAAsB,EACtB,OAAO,EACP,aAAa,EACb,UAAU,GACX,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,CAAA;CACnB,GAAI,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAsBvC;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,CAwFvC"}
|
|
@@ -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;AAChB,CAAC;AAtC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K,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,KAAK,GAAG,CAAC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C,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.1",
|
|
4
4
|
"description": "Apollo Gateway",
|
|
5
5
|
"author": "Apollo <packages@apollographql.com>",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,22 +27,22 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@apollo/core-schema": "^0.2.0",
|
|
29
29
|
"@apollo/federation": "^0.33.8",
|
|
30
|
-
"@apollo/query-planner": "^0.6.
|
|
30
|
+
"@apollo/query-planner": "^0.6.3",
|
|
31
31
|
"@opentelemetry/api": "^1.0.1",
|
|
32
32
|
"@types/node-fetch": "2.5.12",
|
|
33
33
|
"apollo-graphql": "^0.9.5",
|
|
34
|
-
"apollo-reporting-protobuf": "^0.8.0 || ^3.0.0",
|
|
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": "9839faec4505baba5c1ee72bd8981fdeb92a8b3a"
|
|
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
|
|