@apollo/gateway 2.4.5 → 2.4.7

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.
Files changed (67) hide show
  1. package/dist/__generated__/graphqlTypes.d.ts +19 -1
  2. package/dist/__generated__/graphqlTypes.d.ts.map +1 -1
  3. package/dist/__generated__/graphqlTypes.js +1 -0
  4. package/dist/__generated__/graphqlTypes.js.map +1 -1
  5. package/dist/executeQueryPlan.js +1 -1
  6. package/dist/executeQueryPlan.js.map +1 -1
  7. package/package.json +4 -4
  8. package/src/__generated__/graphqlTypes.ts +33 -2
  9. package/src/executeQueryPlan.ts +1 -1
  10. package/src/__mocks__/tsconfig.json +0 -7
  11. package/src/__tests__/.gitkeep +0 -0
  12. package/src/__tests__/CucumberREADME.md +0 -96
  13. package/src/__tests__/build-query-plan.feature +0 -1471
  14. package/src/__tests__/buildQueryPlan.test.ts +0 -1225
  15. package/src/__tests__/executeQueryPlan.conditions.test.ts +0 -1488
  16. package/src/__tests__/executeQueryPlan.introspection.test.ts +0 -140
  17. package/src/__tests__/executeQueryPlan.test.ts +0 -6140
  18. package/src/__tests__/execution-utils.ts +0 -124
  19. package/src/__tests__/gateway/__snapshots__/opentelemetry.test.ts.snap +0 -195
  20. package/src/__tests__/gateway/buildService.test.ts +0 -249
  21. package/src/__tests__/gateway/endToEnd.test.ts +0 -486
  22. package/src/__tests__/gateway/executor.test.ts +0 -96
  23. package/src/__tests__/gateway/extensions.test.ts +0 -37
  24. package/src/__tests__/gateway/lifecycle-hooks.test.ts +0 -239
  25. package/src/__tests__/gateway/opentelemetry.test.ts +0 -123
  26. package/src/__tests__/gateway/queryPlanCache.test.ts +0 -231
  27. package/src/__tests__/gateway/queryPlannerConfig.test.ts +0 -101
  28. package/src/__tests__/gateway/reporting.test.ts +0 -616
  29. package/src/__tests__/gateway/supergraphSdl.test.ts +0 -396
  30. package/src/__tests__/gateway/testUtils.ts +0 -89
  31. package/src/__tests__/integration/abstract-types.test.ts +0 -1861
  32. package/src/__tests__/integration/aliases.test.ts +0 -180
  33. package/src/__tests__/integration/boolean.test.ts +0 -279
  34. package/src/__tests__/integration/complex-key.test.ts +0 -197
  35. package/src/__tests__/integration/configuration.test.ts +0 -404
  36. package/src/__tests__/integration/custom-directives.test.ts +0 -174
  37. package/src/__tests__/integration/execution-style.test.ts +0 -35
  38. package/src/__tests__/integration/fragments.test.ts +0 -237
  39. package/src/__tests__/integration/list-key.test.ts +0 -128
  40. package/src/__tests__/integration/logger.test.ts +0 -122
  41. package/src/__tests__/integration/managed.test.ts +0 -319
  42. package/src/__tests__/integration/merge-arrays.test.ts +0 -34
  43. package/src/__tests__/integration/multiple-key.test.ts +0 -327
  44. package/src/__tests__/integration/mutations.test.ts +0 -287
  45. package/src/__tests__/integration/networkRequests.test.ts +0 -542
  46. package/src/__tests__/integration/nockMocks.ts +0 -157
  47. package/src/__tests__/integration/provides.test.ts +0 -77
  48. package/src/__tests__/integration/requires.test.ts +0 -359
  49. package/src/__tests__/integration/scope.test.ts +0 -557
  50. package/src/__tests__/integration/single-service.test.ts +0 -119
  51. package/src/__tests__/integration/unions.test.ts +0 -79
  52. package/src/__tests__/integration/value-types.test.ts +0 -382
  53. package/src/__tests__/integration/variables.test.ts +0 -120
  54. package/src/__tests__/nockAssertions.ts +0 -20
  55. package/src/__tests__/queryPlanCucumber.test.ts +0 -55
  56. package/src/__tests__/resultShaping.test.ts +0 -605
  57. package/src/__tests__/testSetup.ts +0 -1
  58. package/src/__tests__/tsconfig.json +0 -8
  59. package/src/core/__tests__/core.test.ts +0 -412
  60. package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +0 -51
  61. package/src/datasources/__tests__/RemoteGraphQLDataSource.test.ts +0 -574
  62. package/src/schema-helper/__tests__/addExtensions.test.ts +0 -70
  63. package/src/supergraphManagers/IntrospectAndCompose/__tests__/IntrospectAndCompose.test.ts +0 -364
  64. package/src/supergraphManagers/IntrospectAndCompose/__tests__/loadServicesFromRemoteEndpoint.test.ts +0 -40
  65. package/src/supergraphManagers/UplinkSupergraphManager/__tests__/UplinkSupergraphManager.test.ts +0 -65
  66. package/src/supergraphManagers/UplinkSupergraphManager/__tests__/loadSupergraphSdlFromStorage.test.ts +0 -511
  67. package/src/utilities/__tests__/deepMerge.test.ts +0 -77
@@ -1,412 +0,0 @@
1
- import { ApolloGateway } from '../../..';
2
- import { graphqlErrorSerializer } from 'apollo-federation-integration-testsuite';
3
-
4
- expect.addSnapshotSerializer(graphqlErrorSerializer);
5
-
6
- describe('core v0.1', () => {
7
- it('throws no errors when using a valid @core v0.1 document', () => {
8
- const supergraphSdl = `#graphql
9
- schema
10
- @core(feature: "https://specs.apollo.dev/core/v0.1")
11
- @core(feature: "https://specs.apollo.dev/join/v0.1") {
12
- query: Query
13
- }
14
-
15
- directive @core(feature: String!) repeatable on SCHEMA
16
-
17
- directive @join__field(
18
- graph: join__Graph
19
- requires: join__FieldSet
20
- provides: join__FieldSet
21
- ) on FIELD_DEFINITION
22
-
23
- directive @join__type(
24
- graph: join__Graph!
25
- key: join__FieldSet
26
- ) repeatable on OBJECT | INTERFACE
27
-
28
- directive @join__owner(graph: join__Graph!) on OBJECT | INTERFACE
29
-
30
- directive @join__graph(name: String!, url: String!) on ENUM_VALUE
31
-
32
- directive @tag(
33
- name: String!
34
- ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
35
-
36
- enum CacheControlScope {
37
- PRIVATE
38
- PUBLIC
39
- }
40
-
41
- scalar join__FieldSet
42
-
43
- enum join__Graph {
44
- WORLD @join__graph(name: "world", url: "https://world.api.com.invalid")
45
- }
46
-
47
- type Query {
48
- hello: String! @join__field(graph: WORLD)
49
- }
50
- `;
51
-
52
- const gateway = new ApolloGateway({
53
- supergraphSdl,
54
- });
55
-
56
- expect(gateway.load()).resolves.toBeTruthy();
57
- });
58
-
59
- it('throws an error when the `for:` @core argument is used in a v0.1 document', () => {
60
- const supergraphSdl = `#graphql
61
- schema
62
- @core(feature: "https://specs.apollo.dev/core/v0.1")
63
- @core(feature: "https://specs.apollo.dev/join/v0.1", for: EXECUTION)
64
- @core(
65
- feature: "https://specs.apollo.dev/something-unsupported/v0.1"
66
- for: SECURITY
67
- ) {
68
- query: Query
69
- }
70
-
71
- directive @core(feature: String!) repeatable on SCHEMA
72
-
73
- directive @join__field(
74
- graph: join__Graph
75
- requires: join__FieldSet
76
- provides: join__FieldSet
77
- ) on FIELD_DEFINITION
78
-
79
- directive @join__type(
80
- graph: join__Graph!
81
- key: join__FieldSet
82
- ) repeatable on OBJECT | INTERFACE
83
-
84
- directive @join__owner(graph: join__Graph!) on OBJECT | INTERFACE
85
-
86
- directive @join__graph(name: String!, url: String!) on ENUM_VALUE
87
-
88
- directive @tag(
89
- name: String!
90
- ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
91
-
92
- enum CacheControlScope {
93
- PRIVATE
94
- PUBLIC
95
- }
96
-
97
- scalar join__FieldSet
98
-
99
- enum join__Graph {
100
- WORLD @join__graph(name: "world", url: "https://world.api.com.invalid")
101
- }
102
-
103
- type Query {
104
- hello: String! @join__field(graph: WORLD)
105
- }
106
- `;
107
-
108
- const gateway = new ApolloGateway({
109
- supergraphSdl,
110
- });
111
-
112
- expect(() => gateway.load()).rejects.toMatchInlineSnapshot(`
113
- Array [
114
- "the \`for:\` argument is unsupported by version v0.1 of the core spec. Please upgrade to at least @core v0.2 (https://specs.apollo.dev/core/v0.2).",
115
- "feature https://specs.apollo.dev/something-unsupported/v0.1 is for: SECURITY but is unsupported",
116
- ]
117
- `);
118
- });
119
- });
120
-
121
- describe('core v0.2', () => {
122
- it("doesn't throw errors when using supported features", async () => {
123
- const supergraphSdl = `#graphql
124
- schema
125
- @core(feature: "https://specs.apollo.dev/core/v0.2")
126
- @core(feature: "https://specs.apollo.dev/join/v0.1", for: EXECUTION)
127
- @core(feature: "https://specs.apollo.dev/tag/v0.2") {
128
- query: Query
129
- }
130
-
131
- directive @core(
132
- feature: String!
133
- as: String
134
- for: core__Purpose
135
- ) repeatable on SCHEMA
136
-
137
- directive @join__field(
138
- graph: join__Graph
139
- requires: join__FieldSet
140
- provides: join__FieldSet
141
- ) on FIELD_DEFINITION
142
-
143
- directive @join__type(
144
- graph: join__Graph!
145
- key: join__FieldSet
146
- ) repeatable on OBJECT | INTERFACE
147
-
148
- directive @join__owner(graph: join__Graph!) on OBJECT | INTERFACE
149
-
150
- directive @join__graph(name: String!, url: String!) on ENUM_VALUE
151
-
152
- directive @tag(
153
- name: String!
154
- ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
155
-
156
- enum CacheControlScope {
157
- PRIVATE
158
- PUBLIC
159
- }
160
-
161
- enum core__Purpose {
162
- """
163
- \`EXECUTION\` features provide metadata necessary to for operation execution.
164
- """
165
- EXECUTION
166
-
167
- """
168
- \`SECURITY\` features provide metadata necessary to securely resolve fields.
169
- """
170
- SECURITY
171
- }
172
-
173
- scalar join__FieldSet
174
-
175
- enum join__Graph {
176
- WORLD @join__graph(name: "world", url: "https://world.api.com.invalid")
177
- }
178
-
179
- type Query {
180
- hello: String! @join__field(graph: WORLD)
181
- }
182
- `;
183
-
184
- const gateway = new ApolloGateway({
185
- supergraphSdl,
186
- });
187
-
188
- expect(gateway.load()).resolves.toBeTruthy();
189
- });
190
-
191
- it("doesn't throw errors when using unsupported features which have no `for:` argument", async () => {
192
- const supergraphSdl = `#graphql
193
- schema
194
- @core(feature: "https://specs.apollo.dev/core/v0.2")
195
- @core(feature: "https://specs.apollo.dev/join/v0.1", for: EXECUTION)
196
- @core(feature: "https://specs.apollo.dev/tag/v0.2")
197
- @core(feature: "https://specs.apollo.dev/unsupported-feature/v0.1") {
198
- query: Query
199
- }
200
-
201
- directive @core(
202
- feature: String!
203
- as: String
204
- for: core__Purpose
205
- ) repeatable on SCHEMA
206
-
207
- directive @join__field(
208
- graph: join__Graph
209
- requires: join__FieldSet
210
- provides: join__FieldSet
211
- ) on FIELD_DEFINITION
212
-
213
- directive @join__type(
214
- graph: join__Graph!
215
- key: join__FieldSet
216
- ) repeatable on OBJECT | INTERFACE
217
-
218
- directive @join__owner(graph: join__Graph!) on OBJECT | INTERFACE
219
-
220
- directive @join__graph(name: String!, url: String!) on ENUM_VALUE
221
-
222
- directive @tag(
223
- name: String!
224
- ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
225
-
226
- enum CacheControlScope {
227
- PRIVATE
228
- PUBLIC
229
- }
230
-
231
- enum core__Purpose {
232
- """
233
- \`EXECUTION\` features provide metadata necessary to for operation execution.
234
- """
235
- EXECUTION
236
-
237
- """
238
- \`SECURITY\` features provide metadata necessary to securely resolve fields.
239
- """
240
- SECURITY
241
- }
242
-
243
- scalar join__FieldSet
244
-
245
- enum join__Graph {
246
- WORLD @join__graph(name: "world", url: "https://world.api.com.invalid")
247
- }
248
-
249
- type Query {
250
- hello: String! @join__field(graph: WORLD)
251
- }
252
- `;
253
-
254
- const gateway = new ApolloGateway({
255
- supergraphSdl,
256
- });
257
-
258
- expect(gateway.load()).resolves.toBeTruthy();
259
- });
260
-
261
- it('throws errors when using unsupported features for EXECUTION', () => {
262
- const supergraphSdl = `#graphql
263
- schema
264
- @core(feature: "https://specs.apollo.dev/core/v0.2")
265
- @core(feature: "https://specs.apollo.dev/join/v0.1", for: EXECUTION)
266
- @core(
267
- feature: "https://specs.apollo.dev/unsupported-feature/v0.1"
268
- for: EXECUTION
269
- ) {
270
- query: Query
271
- }
272
-
273
- directive @core(
274
- feature: String!
275
- as: String
276
- for: core__Purpose
277
- ) repeatable on SCHEMA
278
-
279
- directive @join__field(
280
- graph: join__Graph
281
- requires: join__FieldSet
282
- provides: join__FieldSet
283
- ) on FIELD_DEFINITION
284
-
285
- directive @join__type(
286
- graph: join__Graph!
287
- key: join__FieldSet
288
- ) repeatable on OBJECT | INTERFACE
289
-
290
- directive @join__owner(graph: join__Graph!) on OBJECT | INTERFACE
291
-
292
- directive @join__graph(name: String!, url: String!) on ENUM_VALUE
293
-
294
- directive @tag(
295
- name: String!
296
- ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
297
-
298
- enum CacheControlScope {
299
- PRIVATE
300
- PUBLIC
301
- }
302
-
303
- enum core__Purpose {
304
- """
305
- \`EXECUTION\` features provide metadata necessary to for operation execution.
306
- """
307
- EXECUTION
308
-
309
- """
310
- \`SECURITY\` features provide metadata necessary to securely resolve fields.
311
- """
312
- SECURITY
313
- }
314
-
315
- scalar join__FieldSet
316
-
317
- enum join__Graph {
318
- WORLD @join__graph(name: "world", url: "https://world.api.com.invalid")
319
- }
320
-
321
- type Query {
322
- hello: String! @join__field(graph: WORLD)
323
- }
324
- `;
325
-
326
- const gateway = new ApolloGateway({
327
- supergraphSdl,
328
- });
329
-
330
- expect(() => gateway.load()).rejects.toMatchInlineSnapshot(`
331
- Array [
332
- "feature https://specs.apollo.dev/unsupported-feature/v0.1 is for: EXECUTION but is unsupported",
333
- ]
334
- `);
335
- });
336
-
337
- it('throws errors when using unsupported features for SECURITY', async () => {
338
- const supergraphSdl = `#graphql
339
- schema
340
- @core(feature: "https://specs.apollo.dev/core/v0.2")
341
- @core(feature: "https://specs.apollo.dev/join/v0.1", for: EXECUTION)
342
- @core(
343
- feature: "https://specs.apollo.dev/unsupported-feature/v0.1"
344
- for: SECURITY
345
- ) {
346
- query: Query
347
- }
348
-
349
- directive @core(
350
- feature: String!
351
- as: String
352
- for: core__Purpose
353
- ) repeatable on SCHEMA
354
-
355
- directive @join__field(
356
- graph: join__Graph
357
- requires: join__FieldSet
358
- provides: join__FieldSet
359
- ) on FIELD_DEFINITION
360
-
361
- directive @join__type(
362
- graph: join__Graph!
363
- key: join__FieldSet
364
- ) repeatable on OBJECT | INTERFACE
365
-
366
- directive @join__owner(graph: join__Graph!) on OBJECT | INTERFACE
367
-
368
- directive @join__graph(name: String!, url: String!) on ENUM_VALUE
369
-
370
- directive @tag(
371
- name: String!
372
- ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
373
-
374
- enum CacheControlScope {
375
- PRIVATE
376
- PUBLIC
377
- }
378
-
379
- enum core__Purpose {
380
- """
381
- \`EXECUTION\` features provide metadata necessary to for operation execution.
382
- """
383
- EXECUTION
384
-
385
- """
386
- \`SECURITY\` features provide metadata necessary to securely resolve fields.
387
- """
388
- SECURITY
389
- }
390
-
391
- scalar join__FieldSet
392
-
393
- enum join__Graph {
394
- WORLD @join__graph(name: "world", url: "https://world.api.com.invalid")
395
- }
396
-
397
- type Query {
398
- hello: String! @join__field(graph: WORLD)
399
- }
400
- `;
401
-
402
- const gateway = new ApolloGateway({
403
- supergraphSdl,
404
- });
405
-
406
- expect(() => gateway.load()).rejects.toMatchInlineSnapshot(`
407
- Array [
408
- "feature https://specs.apollo.dev/unsupported-feature/v0.1 is for: SECURITY but is unsupported",
409
- ]
410
- `);
411
- });
412
- });
@@ -1,51 +0,0 @@
1
- import { LocalGraphQLDataSource } from '../LocalGraphQLDataSource';
2
- import { buildSubgraphSchema } from '@apollo/subgraph';
3
- import gql from 'graphql-tag';
4
- import { GraphQLResolverMap } from '@apollo/subgraph/src/schema-helper';
5
- import { GraphQLDataSourceRequestKind } from '../types';
6
- import { GatewayGraphQLRequestContext } from '@apollo/server-gateway-interface';
7
-
8
- describe('constructing requests', () => {
9
- it('accepts context', async () => {
10
- const typeDefs = gql`
11
- type Query {
12
- me: User
13
- }
14
- type User {
15
- id: ID
16
- name: String!
17
- }
18
- `;
19
- const resolvers: GraphQLResolverMap<{ userId: number }> = {
20
- Query: {
21
- me(_, __, { userId }) {
22
- const users = [
23
- { id: 1, name: 'otherGuy' },
24
- { id: 2, name: 'james' },
25
- {
26
- id: 3,
27
- name: 'someoneElse',
28
- },
29
- ];
30
- return users.find((user) => user.id === userId);
31
- },
32
- },
33
- };
34
- const schema = buildSubgraphSchema([{ typeDefs, resolvers }]);
35
-
36
- const DataSource = new LocalGraphQLDataSource(schema);
37
-
38
- const { data } = await DataSource.process({
39
- kind: GraphQLDataSourceRequestKind.INCOMING_OPERATION,
40
- request: {
41
- query: '{ me { name } }',
42
- },
43
- incomingRequestContext: {
44
- context: { userId: 2 },
45
- } as GatewayGraphQLRequestContext<{userId: number}>,
46
- context: { userId: 2 },
47
- });
48
-
49
- expect(data).toEqual({ me: { name: 'james' } });
50
- });
51
- });