@apollo/gateway 2.4.4 → 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 (176) hide show
  1. package/dist/__generated__/graphqlTypes.d.ts +178 -0
  2. package/dist/__generated__/graphqlTypes.d.ts.map +1 -0
  3. package/dist/__generated__/graphqlTypes.js +31 -0
  4. package/dist/__generated__/graphqlTypes.js.map +1 -0
  5. package/dist/config.d.ts +138 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/config.js +60 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/dataRewrites.d.ts +5 -0
  10. package/dist/dataRewrites.d.ts.map +1 -0
  11. package/dist/dataRewrites.js +103 -0
  12. package/dist/dataRewrites.js.map +1 -0
  13. package/dist/datasources/LocalGraphQLDataSource.d.ts +10 -0
  14. package/dist/datasources/LocalGraphQLDataSource.d.ts.map +1 -0
  15. package/dist/datasources/LocalGraphQLDataSource.js +31 -0
  16. package/dist/datasources/LocalGraphQLDataSource.js.map +1 -0
  17. package/dist/datasources/RemoteGraphQLDataSource.d.ts +24 -0
  18. package/dist/datasources/RemoteGraphQLDataSource.d.ts.map +1 -0
  19. package/dist/datasources/RemoteGraphQLDataSource.js +180 -0
  20. package/dist/datasources/RemoteGraphQLDataSource.js.map +1 -0
  21. package/dist/datasources/index.d.ts +4 -0
  22. package/dist/datasources/index.d.ts.map +1 -0
  23. package/dist/datasources/index.js +8 -0
  24. package/dist/datasources/index.js.map +1 -0
  25. package/dist/datasources/parseCacheControlHeader.d.ts +2 -0
  26. package/dist/datasources/parseCacheControlHeader.d.ts.map +1 -0
  27. package/dist/datasources/parseCacheControlHeader.js +16 -0
  28. package/dist/datasources/parseCacheControlHeader.js.map +1 -0
  29. package/dist/datasources/types.d.ts +23 -0
  30. package/dist/datasources/types.d.ts.map +1 -0
  31. package/dist/datasources/types.js +10 -0
  32. package/dist/datasources/types.js.map +1 -0
  33. package/dist/executeQueryPlan.d.ts +15 -0
  34. package/dist/executeQueryPlan.d.ts.map +1 -0
  35. package/dist/executeQueryPlan.js +539 -0
  36. package/dist/executeQueryPlan.js.map +1 -0
  37. package/dist/index.d.ts +113 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +590 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/logger.d.ts +3 -0
  42. package/dist/logger.d.ts.map +1 -0
  43. package/dist/logger.js +15 -0
  44. package/dist/logger.js.map +1 -0
  45. package/dist/operationContext.d.ts +17 -0
  46. package/dist/operationContext.d.ts.map +1 -0
  47. package/dist/operationContext.js +38 -0
  48. package/dist/operationContext.js.map +1 -0
  49. package/dist/resultShaping.d.ts +12 -0
  50. package/dist/resultShaping.d.ts.map +1 -0
  51. package/dist/resultShaping.js +229 -0
  52. package/dist/resultShaping.js.map +1 -0
  53. package/dist/schema-helper/addExtensions.d.ts +3 -0
  54. package/dist/schema-helper/addExtensions.d.ts.map +1 -0
  55. package/dist/schema-helper/addExtensions.js +23 -0
  56. package/dist/schema-helper/addExtensions.js.map +1 -0
  57. package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts +31 -0
  58. package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts.map +1 -0
  59. package/dist/supergraphManagers/IntrospectAndCompose/index.js +112 -0
  60. package/dist/supergraphManagers/IntrospectAndCompose/index.js.map +1 -0
  61. package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.d.ts +12 -0
  62. package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.d.ts.map +1 -0
  63. package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.js +57 -0
  64. package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.js.map +1 -0
  65. package/dist/supergraphManagers/LegacyFetcher/index.d.ts +33 -0
  66. package/dist/supergraphManagers/LegacyFetcher/index.d.ts.map +1 -0
  67. package/dist/supergraphManagers/LegacyFetcher/index.js +149 -0
  68. package/dist/supergraphManagers/LegacyFetcher/index.js.map +1 -0
  69. package/dist/supergraphManagers/LocalCompose/index.d.ts +19 -0
  70. package/dist/supergraphManagers/LocalCompose/index.d.ts.map +1 -0
  71. package/dist/supergraphManagers/LocalCompose/index.js +55 -0
  72. package/dist/supergraphManagers/LocalCompose/index.js.map +1 -0
  73. package/dist/supergraphManagers/UplinkSupergraphManager/index.d.ts +63 -0
  74. package/dist/supergraphManagers/UplinkSupergraphManager/index.d.ts.map +1 -0
  75. package/dist/supergraphManagers/UplinkSupergraphManager/index.js +210 -0
  76. package/dist/supergraphManagers/UplinkSupergraphManager/index.js.map +1 -0
  77. package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts +30 -0
  78. package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts.map +1 -0
  79. package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.js +145 -0
  80. package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.js.map +1 -0
  81. package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.d.ts +14 -0
  82. package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.d.ts.map +1 -0
  83. package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.js +85 -0
  84. package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.js.map +1 -0
  85. package/dist/supergraphManagers/index.d.ts +6 -0
  86. package/dist/supergraphManagers/index.d.ts.map +1 -0
  87. package/dist/supergraphManagers/index.js +27 -0
  88. package/dist/supergraphManagers/index.js.map +1 -0
  89. package/dist/typings/graphql.d.ts +11 -0
  90. package/dist/typings/graphql.d.ts.map +1 -0
  91. package/dist/typings/graphql.js +3 -0
  92. package/dist/typings/graphql.js.map +1 -0
  93. package/dist/utilities/array.d.ts +5 -0
  94. package/dist/utilities/array.d.ts.map +1 -0
  95. package/dist/utilities/array.js +46 -0
  96. package/dist/utilities/array.js.map +1 -0
  97. package/dist/utilities/assert.d.ts +2 -0
  98. package/dist/utilities/assert.d.ts.map +1 -0
  99. package/dist/utilities/assert.js +10 -0
  100. package/dist/utilities/assert.js.map +1 -0
  101. package/dist/utilities/deepMerge.d.ts +2 -0
  102. package/dist/utilities/deepMerge.d.ts.map +1 -0
  103. package/dist/utilities/deepMerge.js +34 -0
  104. package/dist/utilities/deepMerge.js.map +1 -0
  105. package/dist/utilities/graphql.d.ts +5 -0
  106. package/dist/utilities/graphql.d.ts.map +1 -0
  107. package/dist/utilities/graphql.js +28 -0
  108. package/dist/utilities/graphql.js.map +1 -0
  109. package/dist/utilities/opentelemetry.d.ts +10 -0
  110. package/dist/utilities/opentelemetry.d.ts.map +1 -0
  111. package/dist/utilities/opentelemetry.js +19 -0
  112. package/dist/utilities/opentelemetry.js.map +1 -0
  113. package/dist/utilities/predicates.d.ts +2 -0
  114. package/dist/utilities/predicates.d.ts.map +1 -0
  115. package/dist/utilities/predicates.js +11 -0
  116. package/dist/utilities/predicates.js.map +1 -0
  117. package/package.json +4 -4
  118. package/src/__generated__/graphqlTypes.ts +33 -2
  119. package/src/__mocks__/tsconfig.json +0 -7
  120. package/src/__tests__/.gitkeep +0 -0
  121. package/src/__tests__/CucumberREADME.md +0 -96
  122. package/src/__tests__/build-query-plan.feature +0 -1471
  123. package/src/__tests__/buildQueryPlan.test.ts +0 -1225
  124. package/src/__tests__/executeQueryPlan.conditions.test.ts +0 -1488
  125. package/src/__tests__/executeQueryPlan.introspection.test.ts +0 -140
  126. package/src/__tests__/executeQueryPlan.test.ts +0 -6140
  127. package/src/__tests__/execution-utils.ts +0 -124
  128. package/src/__tests__/gateway/__snapshots__/opentelemetry.test.ts.snap +0 -195
  129. package/src/__tests__/gateway/buildService.test.ts +0 -249
  130. package/src/__tests__/gateway/endToEnd.test.ts +0 -486
  131. package/src/__tests__/gateway/executor.test.ts +0 -96
  132. package/src/__tests__/gateway/extensions.test.ts +0 -37
  133. package/src/__tests__/gateway/lifecycle-hooks.test.ts +0 -239
  134. package/src/__tests__/gateway/opentelemetry.test.ts +0 -123
  135. package/src/__tests__/gateway/queryPlanCache.test.ts +0 -231
  136. package/src/__tests__/gateway/queryPlannerConfig.test.ts +0 -101
  137. package/src/__tests__/gateway/reporting.test.ts +0 -616
  138. package/src/__tests__/gateway/supergraphSdl.test.ts +0 -396
  139. package/src/__tests__/gateway/testUtils.ts +0 -89
  140. package/src/__tests__/integration/abstract-types.test.ts +0 -1861
  141. package/src/__tests__/integration/aliases.test.ts +0 -180
  142. package/src/__tests__/integration/boolean.test.ts +0 -279
  143. package/src/__tests__/integration/complex-key.test.ts +0 -197
  144. package/src/__tests__/integration/configuration.test.ts +0 -404
  145. package/src/__tests__/integration/custom-directives.test.ts +0 -174
  146. package/src/__tests__/integration/execution-style.test.ts +0 -35
  147. package/src/__tests__/integration/fragments.test.ts +0 -237
  148. package/src/__tests__/integration/list-key.test.ts +0 -128
  149. package/src/__tests__/integration/logger.test.ts +0 -122
  150. package/src/__tests__/integration/managed.test.ts +0 -319
  151. package/src/__tests__/integration/merge-arrays.test.ts +0 -34
  152. package/src/__tests__/integration/multiple-key.test.ts +0 -327
  153. package/src/__tests__/integration/mutations.test.ts +0 -287
  154. package/src/__tests__/integration/networkRequests.test.ts +0 -542
  155. package/src/__tests__/integration/nockMocks.ts +0 -157
  156. package/src/__tests__/integration/provides.test.ts +0 -77
  157. package/src/__tests__/integration/requires.test.ts +0 -359
  158. package/src/__tests__/integration/scope.test.ts +0 -557
  159. package/src/__tests__/integration/single-service.test.ts +0 -119
  160. package/src/__tests__/integration/unions.test.ts +0 -79
  161. package/src/__tests__/integration/value-types.test.ts +0 -382
  162. package/src/__tests__/integration/variables.test.ts +0 -120
  163. package/src/__tests__/nockAssertions.ts +0 -20
  164. package/src/__tests__/queryPlanCucumber.test.ts +0 -55
  165. package/src/__tests__/resultShaping.test.ts +0 -605
  166. package/src/__tests__/testSetup.ts +0 -1
  167. package/src/__tests__/tsconfig.json +0 -8
  168. package/src/core/__tests__/core.test.ts +0 -412
  169. package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +0 -51
  170. package/src/datasources/__tests__/RemoteGraphQLDataSource.test.ts +0 -574
  171. package/src/schema-helper/__tests__/addExtensions.test.ts +0 -70
  172. package/src/supergraphManagers/IntrospectAndCompose/__tests__/IntrospectAndCompose.test.ts +0 -364
  173. package/src/supergraphManagers/IntrospectAndCompose/__tests__/loadServicesFromRemoteEndpoint.test.ts +0 -40
  174. package/src/supergraphManagers/UplinkSupergraphManager/__tests__/UplinkSupergraphManager.test.ts +0 -65
  175. package/src/supergraphManagers/UplinkSupergraphManager/__tests__/loadSupergraphSdlFromStorage.test.ts +0 -511
  176. 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
- }