@apollo/gateway 2.4.5 → 2.4.6

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 (64) 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/package.json +4 -4
  6. package/src/__generated__/graphqlTypes.ts +33 -2
  7. package/src/__mocks__/tsconfig.json +0 -7
  8. package/src/__tests__/.gitkeep +0 -0
  9. package/src/__tests__/CucumberREADME.md +0 -96
  10. package/src/__tests__/build-query-plan.feature +0 -1471
  11. package/src/__tests__/buildQueryPlan.test.ts +0 -1225
  12. package/src/__tests__/executeQueryPlan.conditions.test.ts +0 -1488
  13. package/src/__tests__/executeQueryPlan.introspection.test.ts +0 -140
  14. package/src/__tests__/executeQueryPlan.test.ts +0 -6140
  15. package/src/__tests__/execution-utils.ts +0 -124
  16. package/src/__tests__/gateway/__snapshots__/opentelemetry.test.ts.snap +0 -195
  17. package/src/__tests__/gateway/buildService.test.ts +0 -249
  18. package/src/__tests__/gateway/endToEnd.test.ts +0 -486
  19. package/src/__tests__/gateway/executor.test.ts +0 -96
  20. package/src/__tests__/gateway/extensions.test.ts +0 -37
  21. package/src/__tests__/gateway/lifecycle-hooks.test.ts +0 -239
  22. package/src/__tests__/gateway/opentelemetry.test.ts +0 -123
  23. package/src/__tests__/gateway/queryPlanCache.test.ts +0 -231
  24. package/src/__tests__/gateway/queryPlannerConfig.test.ts +0 -101
  25. package/src/__tests__/gateway/reporting.test.ts +0 -616
  26. package/src/__tests__/gateway/supergraphSdl.test.ts +0 -396
  27. package/src/__tests__/gateway/testUtils.ts +0 -89
  28. package/src/__tests__/integration/abstract-types.test.ts +0 -1861
  29. package/src/__tests__/integration/aliases.test.ts +0 -180
  30. package/src/__tests__/integration/boolean.test.ts +0 -279
  31. package/src/__tests__/integration/complex-key.test.ts +0 -197
  32. package/src/__tests__/integration/configuration.test.ts +0 -404
  33. package/src/__tests__/integration/custom-directives.test.ts +0 -174
  34. package/src/__tests__/integration/execution-style.test.ts +0 -35
  35. package/src/__tests__/integration/fragments.test.ts +0 -237
  36. package/src/__tests__/integration/list-key.test.ts +0 -128
  37. package/src/__tests__/integration/logger.test.ts +0 -122
  38. package/src/__tests__/integration/managed.test.ts +0 -319
  39. package/src/__tests__/integration/merge-arrays.test.ts +0 -34
  40. package/src/__tests__/integration/multiple-key.test.ts +0 -327
  41. package/src/__tests__/integration/mutations.test.ts +0 -287
  42. package/src/__tests__/integration/networkRequests.test.ts +0 -542
  43. package/src/__tests__/integration/nockMocks.ts +0 -157
  44. package/src/__tests__/integration/provides.test.ts +0 -77
  45. package/src/__tests__/integration/requires.test.ts +0 -359
  46. package/src/__tests__/integration/scope.test.ts +0 -557
  47. package/src/__tests__/integration/single-service.test.ts +0 -119
  48. package/src/__tests__/integration/unions.test.ts +0 -79
  49. package/src/__tests__/integration/value-types.test.ts +0 -382
  50. package/src/__tests__/integration/variables.test.ts +0 -120
  51. package/src/__tests__/nockAssertions.ts +0 -20
  52. package/src/__tests__/queryPlanCucumber.test.ts +0 -55
  53. package/src/__tests__/resultShaping.test.ts +0 -605
  54. package/src/__tests__/testSetup.ts +0 -1
  55. package/src/__tests__/tsconfig.json +0 -8
  56. package/src/core/__tests__/core.test.ts +0 -412
  57. package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +0 -51
  58. package/src/datasources/__tests__/RemoteGraphQLDataSource.test.ts +0 -574
  59. package/src/schema-helper/__tests__/addExtensions.test.ts +0 -70
  60. package/src/supergraphManagers/IntrospectAndCompose/__tests__/IntrospectAndCompose.test.ts +0 -364
  61. package/src/supergraphManagers/IntrospectAndCompose/__tests__/loadServicesFromRemoteEndpoint.test.ts +0 -40
  62. package/src/supergraphManagers/UplinkSupergraphManager/__tests__/UplinkSupergraphManager.test.ts +0 -65
  63. package/src/supergraphManagers/UplinkSupergraphManager/__tests__/loadSupergraphSdlFromStorage.test.ts +0 -511
  64. package/src/utilities/__tests__/deepMerge.test.ts +0 -77
@@ -1,605 +0,0 @@
1
- import { buildSchemaFromAST, parseOperation } from "@apollo/federation-internals"
2
- import { gql } from "apollo-federation-integration-testsuite";
3
- import { computeResponse } from "../resultShaping";
4
-
5
- const introspectionHandling = () => null;
6
-
7
- describe('gateway post-processing', () => {
8
- test('filters unqueried fields', () => {
9
- const schema = buildSchemaFromAST(gql`
10
- type Query {
11
- t: T
12
- v: Int!
13
- }
14
-
15
- type T {
16
- a: Int
17
- b: String
18
- c: [C]
19
- d: Int
20
- }
21
-
22
- interface C {
23
- x: Int
24
- y: Int
25
- }
26
-
27
- type P1 implements C {
28
- id: ID!
29
- x: Int
30
- y: Int
31
- }
32
-
33
- type P2 implements C {
34
- x: Int
35
- y: Int
36
- w: Int
37
- z: Int
38
- }
39
- `);
40
-
41
- const input = {
42
- "t": {
43
- "a": 0,
44
- "b": 'testData',
45
- "c": [{
46
- __typename: 'P1',
47
- id: 'foo',
48
- x: 1,
49
- y: 2,
50
- }, {
51
- __typename: 'P2',
52
- x: 10,
53
- y: 20,
54
- w: 30,
55
- z: 40,
56
- }],
57
- "d": 1,
58
- },
59
- "v": 42
60
- }
61
-
62
- const operation = parseOperation(schema, `
63
- {
64
- t {
65
- a
66
- c {
67
- x
68
- ... on P1 {
69
- x
70
- y
71
- }
72
- ... on P2 {
73
- z
74
- }
75
- }
76
- }
77
- }
78
- `);
79
-
80
- expect(computeResponse({
81
- operation,
82
- input,
83
- introspectionHandling,
84
- })).toMatchInlineSnapshot(`
85
- Object {
86
- "data": Object {
87
- "t": Object {
88
- "a": 0,
89
- "c": Array [
90
- Object {
91
- "x": 1,
92
- "y": 2,
93
- },
94
- Object {
95
- "x": 10,
96
- "z": 40,
97
- },
98
- ],
99
- },
100
- },
101
- "errors": Array [],
102
- }
103
- `);
104
- });
105
-
106
- describe('null propagation for non-nullable types', () => {
107
- const schema = buildSchemaFromAST(gql`
108
- type Query {
109
- tNullable: T
110
- tNonNullable: T!
111
- }
112
-
113
- type T {
114
- a: Int
115
- b: Int!
116
- c: [Int]
117
- d: [Int]!
118
- e: [Int!]
119
- f: [Int!]!
120
- }
121
- `);
122
-
123
- const tObj = {
124
- "a": null,
125
- "b": null,
126
- "c": [24, null, 42, null],
127
- "d": [24, null, 42, null],
128
- "e": [24, null, 42, null],
129
- "f": [24, null, 42, null],
130
- }
131
-
132
- const input = {
133
- "tNullable": tObj,
134
- "tNonNullable": tObj,
135
- }
136
-
137
- test('no propagation on nullable (non-list) type', () => {
138
- const operation = parseOperation(schema, `
139
- {
140
- tNonNullable {
141
- a
142
- }
143
- }
144
- `);
145
-
146
- expect(computeResponse({
147
- operation,
148
- input,
149
- introspectionHandling,
150
- })).toMatchInlineSnapshot(`
151
- Object {
152
- "data": Object {
153
- "tNonNullable": Object {
154
- "a": null,
155
- },
156
- },
157
- "errors": Array [],
158
- }
159
- `);
160
- });
161
-
162
- test('propagation on non-nullable (non-list) type', () => {
163
- const operationNonNullable = parseOperation(schema, `
164
- {
165
- tNonNullable {
166
- b
167
- }
168
- }
169
- `);
170
-
171
- let res = computeResponse({
172
- operation: operationNonNullable,
173
- input,
174
- introspectionHandling,
175
- });
176
- expect(res).toMatchInlineSnapshot(`
177
- Object {
178
- "data": null,
179
- "errors": Array [
180
- [GraphQLError: Cannot return null for non-nullable field T.b.],
181
- ],
182
- }
183
- `);
184
- expect(res.errors[0].path).toStrictEqual(['tNonNullable', 'b']);
185
-
186
-
187
- const operationNullable = parseOperation(schema, `
188
- {
189
- tNullable {
190
- b
191
- }
192
- }
193
- `);
194
-
195
- res = computeResponse({
196
- operation: operationNullable,
197
- input,
198
- introspectionHandling,
199
- });
200
- expect(res).toMatchInlineSnapshot(`
201
- Object {
202
- "data": Object {
203
- "tNullable": null,
204
- },
205
- "errors": Array [
206
- [GraphQLError: Cannot return null for non-nullable field T.b.],
207
- ],
208
- }
209
- `);
210
- expect(res.errors[0].path).toStrictEqual(['tNullable', 'b']);
211
- });
212
-
213
- test('no propagation on nullable list type', () => {
214
- const operation = parseOperation(schema, `
215
- {
216
- tNonNullable {
217
- c
218
- }
219
- }
220
- `);
221
-
222
- expect(computeResponse({
223
- operation,
224
- input,
225
- introspectionHandling,
226
- })).toMatchInlineSnapshot(`
227
- Object {
228
- "data": Object {
229
- "tNonNullable": Object {
230
- "c": Array [
231
- 24,
232
- null,
233
- 42,
234
- null,
235
- ],
236
- },
237
- },
238
- "errors": Array [],
239
- }
240
- `);
241
- });
242
-
243
- test('no propagation on null elements of non-nullable list type with nullable inner element type', () => {
244
- const operationNonNullable = parseOperation(schema, `
245
- {
246
- tNonNullable {
247
- d
248
- }
249
- }
250
- `);
251
-
252
- const res = computeResponse({
253
- operation: operationNonNullable,
254
- input,
255
- introspectionHandling,
256
- });
257
- expect(res).toMatchInlineSnapshot(`
258
- Object {
259
- "data": Object {
260
- "tNonNullable": Object {
261
- "d": Array [
262
- 24,
263
- null,
264
- 42,
265
- null,
266
- ],
267
- },
268
- },
269
- "errors": Array [],
270
- }
271
- `);
272
- });
273
-
274
- test('propagation on null elements of list type with non-nullable inner element type', () => {
275
- const operationNonNullable = parseOperation(schema, `
276
- {
277
- tNonNullable {
278
- e
279
- }
280
- }
281
- `);
282
-
283
- const res = computeResponse({
284
- operation: operationNonNullable,
285
- input,
286
- introspectionHandling,
287
- });
288
- expect(res).toMatchInlineSnapshot(`
289
- Object {
290
- "data": Object {
291
- "tNonNullable": Object {
292
- "e": null,
293
- },
294
- },
295
- "errors": Array [
296
- [GraphQLError: Cannot return null for non-nullable array element of type Int at index 1.],
297
- [GraphQLError: Cannot return null for non-nullable array element of type Int at index 3.],
298
- ],
299
- }
300
- `);
301
- expect(res.errors[0].path).toStrictEqual(['tNonNullable', 'e', 1]);
302
- expect(res.errors[1].path).toStrictEqual(['tNonNullable', 'e', 3]);
303
- });
304
-
305
- test('propagation on null elements of non-nullable list type with non-nullable inner element type', () => {
306
- const operationNonNullable = parseOperation(schema, `
307
- {
308
- tNonNullable {
309
- f
310
- }
311
- }
312
- `);
313
-
314
- let res = computeResponse({
315
- operation: operationNonNullable,
316
- input,
317
- introspectionHandling,
318
- });
319
- expect(res).toMatchInlineSnapshot(`
320
- Object {
321
- "data": null,
322
- "errors": Array [
323
- [GraphQLError: Cannot return null for non-nullable array element of type Int at index 1.],
324
- [GraphQLError: Cannot return null for non-nullable array element of type Int at index 3.],
325
- ],
326
- }
327
- `);
328
- expect(res.errors[0].path).toStrictEqual(['tNonNullable', 'f', 1]);
329
- expect(res.errors[1].path).toStrictEqual(['tNonNullable', 'f', 3]);
330
-
331
- const operationNullable = parseOperation(schema, `
332
- {
333
- tNullable {
334
- f
335
- }
336
- }
337
- `);
338
-
339
- res = computeResponse({
340
- operation: operationNullable,
341
- input,
342
- introspectionHandling,
343
- });
344
- expect(res).toMatchInlineSnapshot(`
345
- Object {
346
- "data": Object {
347
- "tNullable": null,
348
- },
349
- "errors": Array [
350
- [GraphQLError: Cannot return null for non-nullable array element of type Int at index 1.],
351
- [GraphQLError: Cannot return null for non-nullable array element of type Int at index 3.],
352
- ],
353
- }
354
- `);
355
- expect(res.errors[0].path).toStrictEqual(['tNullable', 'f', 1]);
356
- expect(res.errors[1].path).toStrictEqual(['tNullable', 'f', 3]);
357
- });
358
- });
359
-
360
- test('handles invalid values for native scalars', () => {
361
- const schema = buildSchemaFromAST(gql`
362
- type Query {
363
- x: Int!
364
- }
365
- `);
366
-
367
- const input = {
368
- "x": 'foo',
369
- }
370
-
371
- const operation = parseOperation(schema, `
372
- {
373
- x
374
- }
375
- `);
376
-
377
- const res = computeResponse({
378
- operation,
379
- input,
380
- introspectionHandling,
381
- });
382
- expect(res).toMatchInlineSnapshot(`
383
- Object {
384
- "data": null,
385
- "errors": Array [
386
- [GraphQLError: Invalid value found for field Query.x.],
387
- ],
388
- }
389
- `);
390
- expect(res.errors[0].path).toStrictEqual(['x']);
391
- });
392
-
393
- test('Adds __typename for root types if necessary', () => {
394
- const schema = buildSchemaFromAST(gql`
395
- type Query {
396
- t: T
397
- }
398
-
399
- type T {
400
- a: Int
401
- q: Query
402
- }
403
- `);
404
-
405
- const input = {
406
- "t": {
407
- "a": 42,
408
- "q": {
409
- "t": {
410
- "q": {
411
- "t": {
412
- "a": 24
413
- },
414
- },
415
- },
416
- },
417
- },
418
- }
419
-
420
- const operation = parseOperation(schema, `
421
- {
422
- __typename
423
- t {
424
- a
425
- q {
426
- __typename
427
- t {
428
- q {
429
- __typename
430
- t {
431
- a
432
- }
433
- }
434
- }
435
- }
436
- }
437
- }
438
- `);
439
-
440
- expect(computeResponse({
441
- operation,
442
- input,
443
- introspectionHandling,
444
- })).toMatchInlineSnapshot(`
445
- Object {
446
- "data": Object {
447
- "__typename": "Query",
448
- "t": Object {
449
- "a": 42,
450
- "q": Object {
451
- "__typename": "Query",
452
- "t": Object {
453
- "q": Object {
454
- "__typename": "Query",
455
- "t": Object {
456
- "a": 24,
457
- },
458
- },
459
- },
460
- },
461
- },
462
- },
463
- "errors": Array [],
464
- }
465
- `);
466
- });
467
-
468
- test('Handles __typename from subgraphs correctly', () => {
469
- const schema = buildSchemaFromAST(gql`
470
- type Query {
471
- i: [I]
472
- }
473
-
474
- interface I {
475
- x: Int
476
- }
477
-
478
- type A implements I {
479
- x: Int
480
- }
481
-
482
- type B implements I {
483
- x: Int
484
- }
485
- `);
486
-
487
- const input = {
488
- "i": [
489
- {
490
- "__typename": "A",
491
- "x": 24,
492
- },
493
- {
494
- "__typename": "B",
495
- "x": 42,
496
- },
497
- ]
498
- }
499
-
500
- const operation = parseOperation(schema, `
501
- {
502
- i {
503
- ... on I {
504
- __typename
505
- x
506
- }
507
- }
508
- }
509
- `);
510
-
511
- expect(computeResponse({
512
- operation,
513
- input,
514
- introspectionHandling,
515
- })).toMatchInlineSnapshot(`
516
- Object {
517
- "data": Object {
518
- "i": Array [
519
- Object {
520
- "__typename": "A",
521
- "x": 24,
522
- },
523
- Object {
524
- "__typename": "B",
525
- "x": 42,
526
- },
527
- ],
528
- },
529
- "errors": Array [],
530
- }
531
- `);
532
- });
533
-
534
- test('Handles defaulted `if` conditions', () => {
535
- const schema = buildSchemaFromAST(gql`
536
- type Query {
537
- hello: String!
538
- }
539
- `);
540
-
541
- const input = {
542
- skipped: 'world',
543
- included: 'world',
544
- };
545
-
546
- const operation = parseOperation(schema, `#graphql
547
- query DefaultedIfCondition($if: Boolean = true) {
548
- skipped: hello @skip(if: $if)
549
- included: hello @include(if: $if)
550
- }
551
- `);
552
-
553
- expect(
554
- computeResponse({
555
- operation,
556
- input,
557
- introspectionHandling,
558
- }),
559
- ).toMatchInlineSnapshot(`
560
- Object {
561
- "data": Object {
562
- "included": "world",
563
- },
564
- "errors": Array [],
565
- }
566
- `);
567
- });
568
-
569
- test('Provided variables overwrite defaulted variable values', () => {
570
- const schema = buildSchemaFromAST(gql`
571
- type Query {
572
- hello: String!
573
- }
574
- `);
575
-
576
- const input = {
577
- skipped: 'world',
578
- included: 'world',
579
- };
580
-
581
- const operation = parseOperation(schema, `#graphql
582
- # note that the default conditional is inverted from the previous test
583
- query DefaultedIfCondition($if: Boolean = false) {
584
- skipped: hello @skip(if: $if)
585
- included: hello @include(if: $if)
586
- }
587
- `);
588
-
589
- expect(
590
- computeResponse({
591
- operation,
592
- input,
593
- variables: { if: true },
594
- introspectionHandling,
595
- }),
596
- ).toMatchInlineSnapshot(`
597
- Object {
598
- "data": Object {
599
- "included": "world",
600
- },
601
- "errors": Array [],
602
- }
603
- `);
604
- });
605
- })
@@ -1 +0,0 @@
1
- import 'apollo-federation-integration-testsuite/dist/matchers';
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.test",
3
- "include": ["**/*"],
4
- "references": [
5
- { "path": "../../" },
6
- { "path": "../../../federation-integration-testsuite-js" },
7
- ]
8
- }