@apollo/gateway 0.46.0-alpha.0 → 0.48.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/dist/datasources/LocalGraphQLDataSource.js.map +1 -1
- package/dist/datasources/RemoteGraphQLDataSource.d.ts.map +1 -1
- package/dist/datasources/RemoteGraphQLDataSource.js +4 -1
- package/dist/datasources/RemoteGraphQLDataSource.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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/schema-helper/addResolversToSchema.d.ts +4 -0
- package/dist/schema-helper/addResolversToSchema.d.ts.map +1 -0
- package/dist/schema-helper/addResolversToSchema.js +62 -0
- package/dist/schema-helper/addResolversToSchema.js.map +1 -0
- package/dist/schema-helper/error.d.ts +6 -0
- package/dist/schema-helper/error.d.ts.map +1 -0
- package/dist/schema-helper/error.js +14 -0
- package/dist/schema-helper/error.js.map +1 -0
- package/dist/schema-helper/index.d.ts +4 -0
- package/dist/schema-helper/index.d.ts.map +1 -0
- package/dist/schema-helper/index.js +16 -0
- package/dist/schema-helper/index.js.map +1 -0
- package/dist/schema-helper/resolverMap.d.ts +16 -0
- package/dist/schema-helper/resolverMap.d.ts.map +1 -0
- package/dist/schema-helper/resolverMap.js +3 -0
- package/dist/schema-helper/resolverMap.js.map +1 -0
- package/dist/supergraphManagers/LegacyFetcher/index.js +1 -1
- package/dist/supergraphManagers/LocalCompose/index.js +1 -1
- package/dist/supergraphManagers/LocalCompose/index.js.map +1 -1
- package/dist/supergraphManagers/UplinkFetcher/index.d.ts +1 -0
- package/dist/supergraphManagers/UplinkFetcher/index.d.ts.map +1 -1
- package/dist/supergraphManagers/UplinkFetcher/index.js +2 -0
- package/dist/supergraphManagers/UplinkFetcher/index.js.map +1 -1
- package/dist/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.d.ts +5 -1
- package/dist/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.d.ts.map +1 -1
- package/dist/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.js +29 -31
- package/dist/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.js.map +1 -1
- package/dist/supergraphManagers/index.d.ts +1 -0
- package/dist/supergraphManagers/index.d.ts.map +1 -1
- package/dist/supergraphManagers/index.js +3 -1
- package/dist/supergraphManagers/index.js.map +1 -1
- package/package.json +11 -10
- package/src/__mocks__/make-fetch-happen-fetcher.ts +3 -1
- package/src/__tests__/executeQueryPlan.test.ts +1 -1
- package/src/__tests__/execution-utils.ts +1 -1
- package/src/__tests__/gateway/buildService.test.ts +1 -1
- package/src/__tests__/gateway/endToEnd.test.ts +1 -1
- package/src/__tests__/gateway/executor.test.ts +1 -1
- package/src/__tests__/gateway/reporting.test.ts +40 -13
- package/src/__tests__/gateway/supergraphSdl.test.ts +6 -2
- package/src/__tests__/integration/nockMocks.ts +3 -2
- package/src/datasources/LocalGraphQLDataSource.ts +1 -1
- package/src/datasources/RemoteGraphQLDataSource.ts +8 -2
- package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +1 -1
- package/src/datasources/__tests__/RemoteGraphQLDataSource.test.ts +4 -4
- package/src/executeQueryPlan.ts +3 -1
- package/src/index.ts +4 -1
- package/src/schema-helper/addResolversToSchema.ts +83 -0
- package/src/schema-helper/error.ts +11 -0
- package/src/schema-helper/index.ts +3 -0
- package/src/schema-helper/resolverMap.ts +23 -0
- package/src/supergraphManagers/LegacyFetcher/index.ts +1 -1
- package/src/supergraphManagers/LocalCompose/index.ts +1 -1
- package/src/supergraphManagers/UplinkFetcher/__tests__/loadSupergraphSdlFromStorage.test.ts +82 -28
- package/src/supergraphManagers/UplinkFetcher/index.ts +2 -0
- package/src/supergraphManagers/UplinkFetcher/loadSupergraphSdlFromStorage.ts +31 -26
- package/src/supergraphManagers/index.ts +1 -0
- package/src/utilities/__tests__/cleanErrorOfInaccessibleElements.test.ts +5 -5
- package/CHANGELOG.md +0 -495
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GraphQLFieldResolver, GraphQLScalarType, DocumentNode } from 'graphql';
|
|
2
|
+
|
|
3
|
+
export interface GraphQLSchemaModule {
|
|
4
|
+
typeDefs: DocumentNode;
|
|
5
|
+
resolvers?: GraphQLResolverMap<any>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
9
|
+
export interface GraphQLResolverMap<TContext = {}> {
|
|
10
|
+
[typeName: string]:
|
|
11
|
+
| {
|
|
12
|
+
[fieldName: string]:
|
|
13
|
+
| GraphQLFieldResolver<any, TContext, any>
|
|
14
|
+
| {
|
|
15
|
+
requires?: string;
|
|
16
|
+
resolve: GraphQLFieldResolver<any, TContext, any>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
| GraphQLScalarType
|
|
20
|
+
| {
|
|
21
|
+
[enumValue: string]: string | number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -222,7 +222,7 @@ export class LegacyFetcher implements SupergraphManager {
|
|
|
222
222
|
|
|
223
223
|
private logUpdateFailure(e: any) {
|
|
224
224
|
this.config.logger?.error(
|
|
225
|
-
'
|
|
225
|
+
'LegacyFetcher failed to update supergraph with the following error: ' +
|
|
226
226
|
(e.message ?? e),
|
|
227
227
|
);
|
|
228
228
|
}
|
|
@@ -76,7 +76,7 @@ export class LocalCompose implements SupergraphManager {
|
|
|
76
76
|
|
|
77
77
|
private logUpdateFailure(e: any) {
|
|
78
78
|
this.config.logger?.error(
|
|
79
|
-
'
|
|
79
|
+
'LocalCompose failed to update supergraph with the following error: ' +
|
|
80
80
|
(e.message ?? e),
|
|
81
81
|
);
|
|
82
82
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadSupergraphSdlFromStorage,
|
|
3
|
-
loadSupergraphSdlFromUplinks
|
|
3
|
+
loadSupergraphSdlFromUplinks,
|
|
4
|
+
UplinkFetcherError,
|
|
4
5
|
} from '../loadSupergraphSdlFromStorage';
|
|
5
6
|
import { getDefaultFetcher } from '../../..';
|
|
6
7
|
import {
|
|
@@ -62,7 +63,8 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
62
63
|
errorReportingEndpoint: undefined,
|
|
63
64
|
fetcher,
|
|
64
65
|
compositionId: "originalId-1234",
|
|
65
|
-
maxRetries: 1
|
|
66
|
+
maxRetries: 1,
|
|
67
|
+
roundRobinSeed: 0,
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
expect(result).toMatchObject({
|
|
@@ -84,10 +86,13 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
84
86
|
errorReportingEndpoint: undefined,
|
|
85
87
|
fetcher,
|
|
86
88
|
compositionId: "originalId-1234",
|
|
87
|
-
maxRetries: 1
|
|
89
|
+
maxRetries: 1,
|
|
90
|
+
roundRobinSeed: 0,
|
|
88
91
|
}),
|
|
89
|
-
).rejects.
|
|
90
|
-
|
|
92
|
+
).rejects.toThrowError(
|
|
93
|
+
new UplinkFetcherError(
|
|
94
|
+
"An error occurred while fetching your schema from Apollo: 500 Internal Server Error",
|
|
95
|
+
)
|
|
91
96
|
);
|
|
92
97
|
})
|
|
93
98
|
|
|
@@ -105,8 +110,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
105
110
|
fetcher,
|
|
106
111
|
compositionId: null,
|
|
107
112
|
}),
|
|
108
|
-
).rejects.
|
|
109
|
-
|
|
113
|
+
).rejects.toThrowError(
|
|
114
|
+
new UplinkFetcherError(
|
|
115
|
+
"An error occurred while fetching your schema from Apollo: 200 invalid json response body at https://example1.cloud-config-url.com/cloudconfig/ reason: Unexpected token I in JSON at position 0"
|
|
116
|
+
)
|
|
110
117
|
);
|
|
111
118
|
});
|
|
112
119
|
|
|
@@ -129,7 +136,9 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
129
136
|
fetcher,
|
|
130
137
|
compositionId: null,
|
|
131
138
|
}),
|
|
132
|
-
).rejects.toThrowError(
|
|
139
|
+
).rejects.toThrowError(
|
|
140
|
+
new UplinkFetcherError(`An error occurred while fetching your schema from Apollo: \n${message}`)
|
|
141
|
+
);
|
|
133
142
|
});
|
|
134
143
|
|
|
135
144
|
it("throws on non-OK status codes when `errors` isn't present in a JSON response", async () => {
|
|
@@ -146,8 +155,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
146
155
|
fetcher,
|
|
147
156
|
compositionId: null,
|
|
148
157
|
}),
|
|
149
|
-
).rejects.
|
|
150
|
-
|
|
158
|
+
).rejects.toThrowError(
|
|
159
|
+
new UplinkFetcherError(
|
|
160
|
+
"An error occurred while fetching your schema from Apollo: 500 Internal Server Error"
|
|
161
|
+
)
|
|
151
162
|
);
|
|
152
163
|
});
|
|
153
164
|
|
|
@@ -166,8 +177,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
166
177
|
fetcher,
|
|
167
178
|
compositionId: null,
|
|
168
179
|
}),
|
|
169
|
-
).rejects.
|
|
170
|
-
|
|
180
|
+
).rejects.toThrowError(
|
|
181
|
+
new UplinkFetcherError(
|
|
182
|
+
"An error occurred while fetching your schema from Apollo: 400 invalid json response body at https://example1.cloud-config-url.com/cloudconfig/ reason: Unexpected end of JSON input",
|
|
183
|
+
)
|
|
171
184
|
);
|
|
172
185
|
});
|
|
173
186
|
|
|
@@ -185,8 +198,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
185
198
|
fetcher,
|
|
186
199
|
compositionId: null,
|
|
187
200
|
}),
|
|
188
|
-
).rejects.
|
|
189
|
-
|
|
201
|
+
).rejects.toThrowError(
|
|
202
|
+
new UplinkFetcherError(
|
|
203
|
+
"An error occurred while fetching your schema from Apollo: 400 invalid json response body at https://example1.cloud-config-url.com/cloudconfig/ reason: Unexpected end of JSON input",
|
|
204
|
+
)
|
|
190
205
|
);
|
|
191
206
|
});
|
|
192
207
|
|
|
@@ -204,8 +219,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
204
219
|
fetcher,
|
|
205
220
|
compositionId: null,
|
|
206
221
|
}),
|
|
207
|
-
).rejects.
|
|
208
|
-
|
|
222
|
+
).rejects.toThrowError(
|
|
223
|
+
new UplinkFetcherError(
|
|
224
|
+
"An error occurred while fetching your schema from Apollo: 413 Payload Too Large",
|
|
225
|
+
)
|
|
209
226
|
);
|
|
210
227
|
});
|
|
211
228
|
|
|
@@ -223,8 +240,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
223
240
|
fetcher,
|
|
224
241
|
compositionId: null,
|
|
225
242
|
}),
|
|
226
|
-
).rejects.
|
|
227
|
-
|
|
243
|
+
).rejects.toThrowError(
|
|
244
|
+
new UplinkFetcherError(
|
|
245
|
+
"An error occurred while fetching your schema from Apollo: 422 Unprocessable Entity",
|
|
246
|
+
)
|
|
228
247
|
);
|
|
229
248
|
});
|
|
230
249
|
|
|
@@ -242,8 +261,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
242
261
|
fetcher,
|
|
243
262
|
compositionId: null,
|
|
244
263
|
}),
|
|
245
|
-
).rejects.
|
|
246
|
-
|
|
264
|
+
).rejects.toThrowError(
|
|
265
|
+
new UplinkFetcherError(
|
|
266
|
+
"An error occurred while fetching your schema from Apollo: 408 Request Timeout",
|
|
267
|
+
)
|
|
247
268
|
);
|
|
248
269
|
});
|
|
249
270
|
});
|
|
@@ -263,8 +284,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
263
284
|
fetcher,
|
|
264
285
|
compositionId: null,
|
|
265
286
|
}),
|
|
266
|
-
).rejects.
|
|
267
|
-
|
|
287
|
+
).rejects.toThrowError(
|
|
288
|
+
new UplinkFetcherError(
|
|
289
|
+
"An error occurred while fetching your schema from Apollo: 504 Gateway Timeout",
|
|
290
|
+
)
|
|
268
291
|
);
|
|
269
292
|
});
|
|
270
293
|
|
|
@@ -282,8 +305,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
282
305
|
fetcher,
|
|
283
306
|
compositionId: null,
|
|
284
307
|
}),
|
|
285
|
-
).rejects.
|
|
286
|
-
|
|
308
|
+
).rejects.toThrowError(
|
|
309
|
+
new UplinkFetcherError(
|
|
310
|
+
"An error occurred while fetching your schema from Apollo: request to https://example1.cloud-config-url.com/cloudconfig/ failed, reason: no response",
|
|
311
|
+
)
|
|
287
312
|
);
|
|
288
313
|
});
|
|
289
314
|
|
|
@@ -301,8 +326,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
301
326
|
fetcher,
|
|
302
327
|
compositionId: null,
|
|
303
328
|
}),
|
|
304
|
-
).rejects.
|
|
305
|
-
|
|
329
|
+
).rejects.toThrowError(
|
|
330
|
+
new UplinkFetcherError(
|
|
331
|
+
"An error occurred while fetching your schema from Apollo: 502 Bad Gateway",
|
|
332
|
+
)
|
|
306
333
|
);
|
|
307
334
|
});
|
|
308
335
|
|
|
@@ -320,8 +347,10 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
320
347
|
fetcher,
|
|
321
348
|
compositionId: null,
|
|
322
349
|
}),
|
|
323
|
-
).rejects.
|
|
324
|
-
|
|
350
|
+
).rejects.toThrowError(
|
|
351
|
+
new UplinkFetcherError(
|
|
352
|
+
"An error occurred while fetching your schema from Apollo: 503 Service Unavailable",
|
|
353
|
+
)
|
|
325
354
|
);
|
|
326
355
|
});
|
|
327
356
|
|
|
@@ -341,3 +370,28 @@ describe('loadSupergraphSdlFromStorage', () => {
|
|
|
341
370
|
});
|
|
342
371
|
});
|
|
343
372
|
|
|
373
|
+
|
|
374
|
+
describe("loadSupergraphSdlFromUplinks", () => {
|
|
375
|
+
beforeEach(nockBeforeEach);
|
|
376
|
+
afterEach(nockAfterEach);
|
|
377
|
+
|
|
378
|
+
it("doesn't retry in the unchanged / null case", async () => {
|
|
379
|
+
mockSupergraphSdlRequestIfAfterUnchanged("id-1234", mockCloudConfigUrl1);
|
|
380
|
+
|
|
381
|
+
const fetcher = jest.fn(getDefaultFetcher());
|
|
382
|
+
const result = await loadSupergraphSdlFromUplinks({
|
|
383
|
+
graphRef,
|
|
384
|
+
apiKey,
|
|
385
|
+
endpoints: [mockCloudConfigUrl1, mockCloudConfigUrl2],
|
|
386
|
+
errorReportingEndpoint: mockOutOfBandReporterUrl,
|
|
387
|
+
fetcher: fetcher as any,
|
|
388
|
+
compositionId: "id-1234",
|
|
389
|
+
maxRetries: 5,
|
|
390
|
+
roundRobinSeed: 0,
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
expect(result).toBeNull();
|
|
394
|
+
expect(fetcher).toHaveBeenCalledTimes(1);
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
|
|
@@ -30,6 +30,7 @@ export class UplinkFetcher implements SupergraphManager {
|
|
|
30
30
|
private errorReportingEndpoint: string | undefined =
|
|
31
31
|
process.env.APOLLO_OUT_OF_BAND_REPORTER_ENDPOINT ?? undefined;
|
|
32
32
|
private compositionId?: string;
|
|
33
|
+
private fetchCount: number = 0;
|
|
33
34
|
|
|
34
35
|
constructor(options: UplinkFetcherOptions) {
|
|
35
36
|
this.config = options;
|
|
@@ -81,6 +82,7 @@ export class UplinkFetcher implements SupergraphManager {
|
|
|
81
82
|
fetcher: this.config.fetcher,
|
|
82
83
|
compositionId: this.compositionId ?? null,
|
|
83
84
|
maxRetries: this.config.maxRetries,
|
|
85
|
+
roundRobinSeed: this.fetchCount++,
|
|
84
86
|
});
|
|
85
87
|
|
|
86
88
|
if (!result) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fetch, Response, Request } from 'apollo-server-env';
|
|
2
2
|
import { GraphQLError } from 'graphql';
|
|
3
|
+
import retry from 'async-retry';
|
|
3
4
|
import { SupergraphSdlUpdate } from '../../config';
|
|
4
5
|
import { submitOutOfBandReportIfConfigured } from './outOfBandReporter';
|
|
5
6
|
import { SupergraphSdlQuery } from '../../__generated__/graphqlTypes';
|
|
@@ -39,7 +40,12 @@ const { name, version } = require('../../../package.json');
|
|
|
39
40
|
|
|
40
41
|
const fetchErrorMsg = "An error occurred while fetching your schema from Apollo: ";
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
export class UplinkFetcherError extends Error {
|
|
44
|
+
constructor(message: string) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = 'UplinkFetcherError';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
43
49
|
|
|
44
50
|
export async function loadSupergraphSdlFromUplinks({
|
|
45
51
|
graphRef,
|
|
@@ -49,6 +55,7 @@ export async function loadSupergraphSdlFromUplinks({
|
|
|
49
55
|
fetcher,
|
|
50
56
|
compositionId,
|
|
51
57
|
maxRetries,
|
|
58
|
+
roundRobinSeed,
|
|
52
59
|
}: {
|
|
53
60
|
graphRef: string;
|
|
54
61
|
apiKey: string;
|
|
@@ -56,29 +63,27 @@ export async function loadSupergraphSdlFromUplinks({
|
|
|
56
63
|
errorReportingEndpoint: string | undefined,
|
|
57
64
|
fetcher: typeof fetch;
|
|
58
65
|
compositionId: string | null;
|
|
59
|
-
maxRetries: number
|
|
66
|
+
maxRetries: number,
|
|
67
|
+
roundRobinSeed: number,
|
|
60
68
|
}) : Promise<SupergraphSdlUpdate | null> {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
// This Promise resolves with either an updated supergraph or null if no change.
|
|
70
|
+
// This Promise can reject in the case that none of the retries are successful,
|
|
71
|
+
// in which case it will reject with the most frequently encountered error.
|
|
72
|
+
return retry(
|
|
73
|
+
() =>
|
|
74
|
+
loadSupergraphSdlFromStorage({
|
|
67
75
|
graphRef,
|
|
68
76
|
apiKey,
|
|
69
|
-
endpoint: endpoints[
|
|
77
|
+
endpoint: endpoints[roundRobinSeed++ % endpoints.length],
|
|
70
78
|
errorReportingEndpoint,
|
|
71
79
|
fetcher,
|
|
72
|
-
compositionId
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
throw lastException;
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
80
|
+
compositionId,
|
|
81
|
+
}),
|
|
82
|
+
{
|
|
83
|
+
retries: maxRetries,
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
export async function loadSupergraphSdlFromStorage({
|
|
@@ -132,7 +137,7 @@ export async function loadSupergraphSdlFromStorage({
|
|
|
132
137
|
fetcher,
|
|
133
138
|
});
|
|
134
139
|
|
|
135
|
-
throw new
|
|
140
|
+
throw new UplinkFetcherError(fetchErrorMsg + (e.message ?? e));
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
const endTime = new Date();
|
|
@@ -143,11 +148,11 @@ export async function loadSupergraphSdlFromStorage({
|
|
|
143
148
|
response = await result.json();
|
|
144
149
|
} catch (e) {
|
|
145
150
|
// Bad response
|
|
146
|
-
throw new
|
|
151
|
+
throw new UplinkFetcherError(fetchErrorMsg + result.status + ' ' + e.message ?? e);
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
if ('errors' in response) {
|
|
150
|
-
throw new
|
|
155
|
+
throw new UplinkFetcherError(
|
|
151
156
|
[fetchErrorMsg, ...response.errors.map((error) => error.message)].join(
|
|
152
157
|
'\n',
|
|
153
158
|
),
|
|
@@ -155,7 +160,7 @@ export async function loadSupergraphSdlFromStorage({
|
|
|
155
160
|
}
|
|
156
161
|
} else {
|
|
157
162
|
await submitOutOfBandReportIfConfigured({
|
|
158
|
-
error: new
|
|
163
|
+
error: new UplinkFetcherError(fetchErrorMsg + result.status + ' ' + result.statusText),
|
|
159
164
|
request,
|
|
160
165
|
endpoint: errorReportingEndpoint,
|
|
161
166
|
response: result,
|
|
@@ -163,7 +168,7 @@ export async function loadSupergraphSdlFromStorage({
|
|
|
163
168
|
endedAt: endTime,
|
|
164
169
|
fetcher,
|
|
165
170
|
});
|
|
166
|
-
throw new
|
|
171
|
+
throw new UplinkFetcherError(fetchErrorMsg + result.status + ' ' + result.statusText);
|
|
167
172
|
}
|
|
168
173
|
|
|
169
174
|
const { routerConfig } = response.data;
|
|
@@ -177,10 +182,10 @@ export async function loadSupergraphSdlFromStorage({
|
|
|
177
182
|
} else if (routerConfig.__typename === 'FetchError') {
|
|
178
183
|
// FetchError case
|
|
179
184
|
const { code, message } = routerConfig;
|
|
180
|
-
throw new
|
|
185
|
+
throw new UplinkFetcherError(`${code}: ${message}`);
|
|
181
186
|
} else if (routerConfig.__typename === 'Unchanged') {
|
|
182
187
|
return null;
|
|
183
188
|
} else {
|
|
184
|
-
throw new
|
|
189
|
+
throw new UplinkFetcherError('Programming error: unhandled response failure');
|
|
185
190
|
}
|
|
186
191
|
}
|
|
@@ -2,3 +2,4 @@ export { LocalCompose } from './LocalCompose';
|
|
|
2
2
|
export { LegacyFetcher } from './LegacyFetcher';
|
|
3
3
|
export { IntrospectAndCompose } from './IntrospectAndCompose';
|
|
4
4
|
export { UplinkFetcher } from './UplinkFetcher';
|
|
5
|
+
export { UplinkFetcherError } from './UplinkFetcher/loadSupergraphSdlFromStorage'
|
|
@@ -49,17 +49,17 @@ describe('cleanErrorOfInaccessibleNames', () => {
|
|
|
49
49
|
schema = toAPISchema(schema);
|
|
50
50
|
|
|
51
51
|
it('removes inaccessible type names from error messages', async () => {
|
|
52
|
-
const result = await execute(schema, parse('{fooField{someField}}'), {
|
|
52
|
+
const result = await execute({ schema, document: parse('{fooField{someField}}'), rootValue: {
|
|
53
53
|
fooField: {
|
|
54
54
|
__typename: 'Bar',
|
|
55
55
|
someField: 'test',
|
|
56
56
|
},
|
|
57
|
-
});
|
|
57
|
+
}});
|
|
58
58
|
|
|
59
59
|
const cleaned = cleanErrorOfInaccessibleNames(schema, result.errors?.[0]!);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
60
|
+
// graphql 15 and 16 changed the error message just a bit, but this is sufficient and will pass for both
|
|
61
|
+
expect(cleaned.message).toContain('Abstract type "Foo" was resolve');
|
|
62
|
+
expect(cleaned.message).toContain("to a type [inaccessible type] that does not exist");
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
it('removes multiple/repeated inaccessible type names from error messages', async () => {
|