@apollo/gateway 0.300.0-alpha.2 → 2.0.0-alpha.2

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 (198) hide show
  1. package/LICENSE +95 -0
  2. package/README.md +1 -1
  3. package/dist/__generated__/graphqlTypes.d.ts +130 -0
  4. package/dist/__generated__/graphqlTypes.d.ts.map +1 -0
  5. package/dist/__generated__/graphqlTypes.js +25 -0
  6. package/dist/__generated__/graphqlTypes.js.map +1 -0
  7. package/dist/config.d.ts +104 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +47 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/datasources/LocalGraphQLDataSource.d.ts +3 -3
  12. package/dist/datasources/LocalGraphQLDataSource.d.ts.map +1 -1
  13. package/dist/datasources/LocalGraphQLDataSource.js +5 -5
  14. package/dist/datasources/LocalGraphQLDataSource.js.map +1 -1
  15. package/dist/datasources/RemoteGraphQLDataSource.d.ts +6 -4
  16. package/dist/datasources/RemoteGraphQLDataSource.d.ts.map +1 -1
  17. package/dist/datasources/RemoteGraphQLDataSource.js +60 -17
  18. package/dist/datasources/RemoteGraphQLDataSource.js.map +1 -1
  19. package/dist/datasources/index.d.ts +1 -1
  20. package/dist/datasources/index.d.ts.map +1 -1
  21. package/dist/datasources/index.js +1 -0
  22. package/dist/datasources/index.js.map +1 -1
  23. package/dist/datasources/parseCacheControlHeader.d.ts +2 -0
  24. package/dist/datasources/parseCacheControlHeader.d.ts.map +1 -0
  25. package/dist/datasources/parseCacheControlHeader.js +16 -0
  26. package/dist/datasources/parseCacheControlHeader.js.map +1 -0
  27. package/dist/datasources/types.d.ts +16 -1
  28. package/dist/datasources/types.d.ts.map +1 -1
  29. package/dist/datasources/types.js +7 -0
  30. package/dist/datasources/types.js.map +1 -1
  31. package/dist/executeQueryPlan.d.ts +2 -1
  32. package/dist/executeQueryPlan.d.ts.map +1 -1
  33. package/dist/executeQueryPlan.js +199 -112
  34. package/dist/executeQueryPlan.js.map +1 -1
  35. package/dist/index.d.ts +62 -80
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +543 -234
  38. package/dist/index.js.map +1 -1
  39. package/dist/loadServicesFromRemoteEndpoint.d.ts +9 -9
  40. package/dist/loadServicesFromRemoteEndpoint.d.ts.map +1 -1
  41. package/dist/loadServicesFromRemoteEndpoint.js +13 -8
  42. package/dist/loadServicesFromRemoteEndpoint.js.map +1 -1
  43. package/dist/loadSupergraphSdlFromStorage.d.ts +13 -0
  44. package/dist/loadSupergraphSdlFromStorage.d.ts.map +1 -0
  45. package/dist/loadSupergraphSdlFromStorage.js +101 -0
  46. package/dist/loadSupergraphSdlFromStorage.js.map +1 -0
  47. package/dist/operationContext.d.ts +17 -0
  48. package/dist/operationContext.d.ts.map +1 -0
  49. package/dist/operationContext.js +42 -0
  50. package/dist/operationContext.js.map +1 -0
  51. package/dist/outOfBandReporter.d.ts +15 -0
  52. package/dist/outOfBandReporter.d.ts.map +1 -0
  53. package/dist/outOfBandReporter.js +88 -0
  54. package/dist/outOfBandReporter.js.map +1 -0
  55. package/dist/utilities/array.d.ts +1 -2
  56. package/dist/utilities/array.d.ts.map +1 -1
  57. package/dist/utilities/array.js +7 -14
  58. package/dist/utilities/array.js.map +1 -1
  59. package/dist/utilities/assert.d.ts +2 -0
  60. package/dist/utilities/assert.d.ts.map +1 -0
  61. package/dist/utilities/assert.js +10 -0
  62. package/dist/utilities/assert.js.map +1 -0
  63. package/dist/utilities/cleanErrorOfInaccessibleNames.d.ts +3 -0
  64. package/dist/utilities/cleanErrorOfInaccessibleNames.d.ts.map +1 -0
  65. package/dist/utilities/cleanErrorOfInaccessibleNames.js +27 -0
  66. package/dist/utilities/cleanErrorOfInaccessibleNames.js.map +1 -0
  67. package/dist/utilities/deepMerge.js +2 -2
  68. package/dist/utilities/deepMerge.js.map +1 -1
  69. package/dist/utilities/graphql.d.ts +1 -4
  70. package/dist/utilities/graphql.d.ts.map +1 -1
  71. package/dist/utilities/graphql.js +3 -36
  72. package/dist/utilities/graphql.js.map +1 -1
  73. package/dist/utilities/opentelemetry.d.ts +10 -0
  74. package/dist/utilities/opentelemetry.d.ts.map +1 -0
  75. package/dist/utilities/opentelemetry.js +19 -0
  76. package/dist/utilities/opentelemetry.js.map +1 -0
  77. package/package.json +30 -21
  78. package/src/__generated__/graphqlTypes.ts +140 -0
  79. package/src/__mocks__/apollo-server-env.ts +56 -0
  80. package/src/__mocks__/make-fetch-happen-fetcher.ts +55 -0
  81. package/src/__mocks__/tsconfig.json +7 -0
  82. package/src/__tests__/build-query-plan.feature +40 -311
  83. package/src/__tests__/buildQueryPlan.test.ts +246 -426
  84. package/src/__tests__/executeQueryPlan.test.ts +1691 -194
  85. package/src/__tests__/execution-utils.ts +33 -26
  86. package/src/__tests__/gateway/__snapshots__/opentelemetry.test.ts.snap +195 -0
  87. package/src/__tests__/gateway/buildService.test.ts +16 -19
  88. package/src/__tests__/gateway/composedSdl.test.ts +44 -0
  89. package/src/__tests__/gateway/endToEnd.test.ts +166 -0
  90. package/src/__tests__/gateway/executor.test.ts +49 -43
  91. package/src/__tests__/gateway/lifecycle-hooks.test.ts +58 -29
  92. package/src/__tests__/gateway/opentelemetry.test.ts +123 -0
  93. package/src/__tests__/gateway/queryPlanCache.test.ts +19 -20
  94. package/src/__tests__/gateway/reporting.test.ts +76 -55
  95. package/src/__tests__/integration/abstract-types.test.ts +1086 -22
  96. package/src/__tests__/integration/aliases.test.ts +5 -6
  97. package/src/__tests__/integration/boolean.test.ts +40 -38
  98. package/src/__tests__/integration/complex-key.test.ts +41 -56
  99. package/src/__tests__/integration/configuration.test.ts +321 -0
  100. package/src/__tests__/integration/custom-directives.test.ts +61 -46
  101. package/src/__tests__/integration/fragments.test.ts +8 -2
  102. package/src/__tests__/integration/list-key.test.ts +2 -2
  103. package/src/__tests__/integration/logger.test.ts +2 -2
  104. package/src/__tests__/integration/multiple-key.test.ts +11 -12
  105. package/src/__tests__/integration/mutations.test.ts +8 -5
  106. package/src/__tests__/integration/networkRequests.test.ts +447 -289
  107. package/src/__tests__/integration/nockMocks.ts +95 -66
  108. package/src/__tests__/integration/provides.test.ts +9 -6
  109. package/src/__tests__/integration/requires.test.ts +17 -15
  110. package/src/__tests__/integration/scope.test.ts +557 -0
  111. package/src/__tests__/integration/unions.test.ts +1 -1
  112. package/src/__tests__/integration/value-types.test.ts +35 -32
  113. package/src/__tests__/integration/variables.test.ts +8 -2
  114. package/src/__tests__/loadServicesFromRemoteEndpoint.test.ts +6 -2
  115. package/src/__tests__/loadSupergraphSdlFromStorage.test.ts +694 -0
  116. package/src/__tests__/queryPlanCucumber.test.ts +11 -61
  117. package/src/__tests__/testSetup.ts +1 -4
  118. package/src/__tests__/tsconfig.json +2 -1
  119. package/src/config.ts +225 -0
  120. package/src/core/__tests__/core.test.ts +412 -0
  121. package/src/datasources/LocalGraphQLDataSource.ts +9 -10
  122. package/src/datasources/RemoteGraphQLDataSource.ts +117 -43
  123. package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +11 -4
  124. package/src/datasources/__tests__/RemoteGraphQLDataSource.test.ts +148 -79
  125. package/src/datasources/__tests__/tsconfig.json +4 -2
  126. package/src/datasources/index.ts +1 -1
  127. package/src/datasources/parseCacheControlHeader.ts +43 -0
  128. package/src/datasources/types.ts +47 -2
  129. package/src/executeQueryPlan.ts +264 -153
  130. package/src/index.ts +925 -480
  131. package/src/loadServicesFromRemoteEndpoint.ts +24 -17
  132. package/src/loadSupergraphSdlFromStorage.ts +140 -0
  133. package/src/make-fetch-happen.d.ts +2 -2
  134. package/src/operationContext.ts +70 -0
  135. package/src/outOfBandReporter.ts +128 -0
  136. package/src/utilities/__tests__/cleanErrorOfInaccessibleElements.test.ts +104 -0
  137. package/src/utilities/__tests__/tsconfig.json +8 -0
  138. package/src/utilities/array.ts +6 -28
  139. package/src/utilities/assert.ts +14 -0
  140. package/src/utilities/cleanErrorOfInaccessibleNames.ts +29 -0
  141. package/src/utilities/graphql.ts +0 -64
  142. package/src/utilities/opentelemetry.ts +13 -0
  143. package/CHANGELOG.md +0 -226
  144. package/LICENSE.md +0 -20
  145. package/dist/FieldSet.d.ts +0 -18
  146. package/dist/FieldSet.d.ts.map +0 -1
  147. package/dist/FieldSet.js +0 -96
  148. package/dist/FieldSet.js.map +0 -1
  149. package/dist/QueryPlan.d.ts +0 -41
  150. package/dist/QueryPlan.d.ts.map +0 -1
  151. package/dist/QueryPlan.js +0 -15
  152. package/dist/QueryPlan.js.map +0 -1
  153. package/dist/buildQueryPlan.d.ts +0 -44
  154. package/dist/buildQueryPlan.d.ts.map +0 -1
  155. package/dist/buildQueryPlan.js +0 -670
  156. package/dist/buildQueryPlan.js.map +0 -1
  157. package/dist/loadServicesFromStorage.d.ts +0 -21
  158. package/dist/loadServicesFromStorage.d.ts.map +0 -1
  159. package/dist/loadServicesFromStorage.js +0 -64
  160. package/dist/loadServicesFromStorage.js.map +0 -1
  161. package/dist/snapshotSerializers/astSerializer.d.ts +0 -3
  162. package/dist/snapshotSerializers/astSerializer.d.ts.map +0 -1
  163. package/dist/snapshotSerializers/astSerializer.js +0 -14
  164. package/dist/snapshotSerializers/astSerializer.js.map +0 -1
  165. package/dist/snapshotSerializers/index.d.ts +0 -13
  166. package/dist/snapshotSerializers/index.d.ts.map +0 -1
  167. package/dist/snapshotSerializers/index.js +0 -15
  168. package/dist/snapshotSerializers/index.js.map +0 -1
  169. package/dist/snapshotSerializers/queryPlanSerializer.d.ts +0 -3
  170. package/dist/snapshotSerializers/queryPlanSerializer.d.ts.map +0 -1
  171. package/dist/snapshotSerializers/queryPlanSerializer.js +0 -78
  172. package/dist/snapshotSerializers/queryPlanSerializer.js.map +0 -1
  173. package/dist/snapshotSerializers/selectionSetSerializer.d.ts +0 -3
  174. package/dist/snapshotSerializers/selectionSetSerializer.d.ts.map +0 -1
  175. package/dist/snapshotSerializers/selectionSetSerializer.js +0 -12
  176. package/dist/snapshotSerializers/selectionSetSerializer.js.map +0 -1
  177. package/dist/snapshotSerializers/typeSerializer.d.ts +0 -3
  178. package/dist/snapshotSerializers/typeSerializer.d.ts.map +0 -1
  179. package/dist/snapshotSerializers/typeSerializer.js +0 -12
  180. package/dist/snapshotSerializers/typeSerializer.js.map +0 -1
  181. package/dist/utilities/MultiMap.d.ts +0 -4
  182. package/dist/utilities/MultiMap.d.ts.map +0 -1
  183. package/dist/utilities/MultiMap.js +0 -17
  184. package/dist/utilities/MultiMap.js.map +0 -1
  185. package/src/FieldSet.ts +0 -169
  186. package/src/QueryPlan.ts +0 -57
  187. package/src/__tests__/matchers/toCallService.ts +0 -105
  188. package/src/__tests__/matchers/toHaveBeenCalledBefore.ts +0 -40
  189. package/src/__tests__/matchers/toHaveFetched.ts +0 -81
  190. package/src/__tests__/matchers/toMatchAST.ts +0 -64
  191. package/src/buildQueryPlan.ts +0 -1190
  192. package/src/loadServicesFromStorage.ts +0 -170
  193. package/src/snapshotSerializers/astSerializer.ts +0 -21
  194. package/src/snapshotSerializers/index.ts +0 -21
  195. package/src/snapshotSerializers/queryPlanSerializer.ts +0 -144
  196. package/src/snapshotSerializers/selectionSetSerializer.ts +0 -13
  197. package/src/snapshotSerializers/typeSerializer.ts +0 -11
  198. package/src/utilities/MultiMap.ts +0 -11
@@ -1,170 +0,0 @@
1
- import { fetch } from 'apollo-server-env';
2
- import { parse } from 'graphql';
3
- import { Experimental_UpdateServiceDefinitions } from '.';
4
-
5
- interface LinkFileResult {
6
- configPath: string;
7
- formatVersion: number;
8
- }
9
-
10
- interface ImplementingService {
11
- formatVersion: number;
12
- graphID: string;
13
- graphVariant: string;
14
- name: string;
15
- revision: string;
16
- url: string;
17
- partialSchemaPath: string;
18
- }
19
-
20
- interface ImplementingServiceLocation {
21
- name: string;
22
- path: string;
23
- }
24
-
25
- export interface CompositionMetadata {
26
- formatVersion: number;
27
- id: string;
28
- implementingServiceLocations: ImplementingServiceLocation[];
29
- schemaHash: string;
30
- }
31
-
32
- const envOverridePartialSchemaBaseUrl = 'APOLLO_PARTIAL_SCHEMA_BASE_URL';
33
- const envOverrideStorageSecretBaseUrl = 'APOLLO_STORAGE_SECRET_BASE_URL';
34
-
35
- const urlFromEnvOrDefault = (envKey: string, fallback: string) =>
36
- (process.env[envKey] || fallback).replace(/\/$/, '');
37
-
38
- // Generate and cache our desired operation manifest URL.
39
- const urlPartialSchemaBase = urlFromEnvOrDefault(
40
- envOverridePartialSchemaBaseUrl,
41
- 'https://federation.api.apollographql.com/',
42
- );
43
-
44
- const urlStorageSecretBase: string = urlFromEnvOrDefault(
45
- envOverrideStorageSecretBaseUrl,
46
- 'https://storage-secrets.api.apollographql.com/',
47
- );
48
-
49
- function getStorageSecretUrl(graphId: string, apiKeyHash: string): string {
50
- return `${urlStorageSecretBase}/${graphId}/storage-secret/${apiKeyHash}.json`;
51
- }
52
-
53
- function fetchApolloGcs(
54
- fetcher: typeof fetch,
55
- ...args: Parameters<typeof fetch>
56
- ): ReturnType<typeof fetch> {
57
- const [input, init] = args;
58
-
59
- // Used in logging.
60
- const url = typeof input === 'object' && input.url || input;
61
-
62
- return fetcher(input, init)
63
- .catch(fetchError => {
64
- throw new Error(
65
- "Cannot access Apollo Graph Manager storage: " + fetchError)
66
- })
67
- .then(async (response) => {
68
- // If the fetcher has a cache and has implemented ETag validation, then
69
- // a 304 response may be returned. Either way, we will return the
70
- // non-JSON-parsed version and let the caller decide if that's important
71
- // to their needs.
72
- if (response.ok || response.status === 304) {
73
- return response;
74
- }
75
-
76
- // We won't make any assumptions that the body is anything but text, to
77
- // avoid parsing errors in this unknown condition.
78
- const body = await response.text();
79
-
80
- // Google Cloud Storage returns an `application/xml` error under error
81
- // conditions. We'll special-case our known errors, and resort to
82
- // printing the body for others.
83
- if (
84
- response.headers.get('content-type') === 'application/xml' &&
85
- response.status === 403 &&
86
- body.includes("<Error><Code>AccessDenied</Code>") &&
87
- body.includes("Anonymous caller does not have storage.objects.get")
88
- ) {
89
- throw new Error(
90
- "Unable to authenticate with Apollo Graph Manager storage " +
91
- "while fetching " + url + ". Ensure that the API key is " +
92
- "configured properly and that a federated service has been " +
93
- "pushed. For details, see " +
94
- "https://go.apollo.dev/g/resolve-access-denied.");
95
- }
96
-
97
- // Normally, we'll try to keep the logs clean with errors we expect.
98
- // If it's not a known error, reveal the full body for debugging.
99
- throw new Error(
100
- "Could not communicate with Apollo Graph Manager storage: " + body);
101
- });
102
- };
103
-
104
- export async function getServiceDefinitionsFromStorage({
105
- graphId,
106
- apiKeyHash,
107
- graphVariant,
108
- federationVersion,
109
- fetcher,
110
- }: {
111
- graphId: string;
112
- apiKeyHash: string;
113
- graphVariant?: string;
114
- federationVersion: number;
115
- fetcher: typeof fetch;
116
- }): ReturnType<Experimental_UpdateServiceDefinitions> {
117
- // fetch the storage secret
118
- const storageSecretUrl = getStorageSecretUrl(graphId, apiKeyHash);
119
-
120
- // The storage secret is a JSON string (e.g. `"secret"`).
121
- const secret: string =
122
- await fetchApolloGcs(fetcher, storageSecretUrl).then(res => res.json());
123
-
124
- if (!graphVariant) {
125
- graphVariant = 'current';
126
- }
127
-
128
- const baseUrl = `${urlPartialSchemaBase}/${secret}/${graphVariant}/v${federationVersion}`;
129
-
130
- const compositionConfigResponse =
131
- await fetchApolloGcs(fetcher, `${baseUrl}/composition-config-link`);
132
-
133
- if (compositionConfigResponse.status === 304) {
134
- return { isNewSchema: false };
135
- }
136
-
137
- const linkFileResult: LinkFileResult = await compositionConfigResponse.json();
138
-
139
- const compositionMetadata: CompositionMetadata = await fetchApolloGcs(
140
- fetcher,
141
- `${urlPartialSchemaBase}/${linkFileResult.configPath}`,
142
- ).then(res => res.json());
143
-
144
- // It's important to maintain the original order here
145
- const serviceDefinitions = await Promise.all(
146
- compositionMetadata.implementingServiceLocations.map(
147
- async ({ name, path }) => {
148
- const { url, partialSchemaPath }: ImplementingService = await fetcher(
149
- `${urlPartialSchemaBase}/${path}`,
150
- ).then(response => response.json());
151
-
152
- const sdl = await fetcher(
153
- `${urlPartialSchemaBase}/${partialSchemaPath}`,
154
- ).then(response => response.text());
155
-
156
- return { name, url, typeDefs: parse(sdl) };
157
- },
158
- ),
159
- );
160
-
161
- // explicity return that this is a new schema, as the link file has changed.
162
- // we can't use the hit property of the fetchPartialSchemaFiles, as the partial
163
- // schema may all be cache hits with the final schema still being new
164
- // (for instance if a partial schema is removed or a partial schema is rolled back to a prior version, which is still in cache)
165
- return {
166
- serviceDefinitions,
167
- compositionMetadata,
168
- isNewSchema: true,
169
- };
170
- }
@@ -1,21 +0,0 @@
1
- import { ASTNode, print } from 'graphql';
2
- import { Plugin, Config, Refs } from 'pretty-format';
3
-
4
- export default {
5
- test(value: any) {
6
- return value && typeof value.kind === 'string';
7
- },
8
-
9
- serialize(
10
- value: ASTNode,
11
- _config: Config,
12
- indentation: string,
13
- _depth: number,
14
- _refs: Refs,
15
- _printer: any,
16
- ): string {
17
- return print(value)
18
- .trim()
19
- .replace(/\n/g, '\n' + indentation);
20
- },
21
- } as Plugin;
@@ -1,21 +0,0 @@
1
- import astSerializer from './astSerializer';
2
- import selectionSetSerializer from './selectionSetSerializer';
3
- import typeSerializer from './typeSerializer';
4
- import queryPlanSerializer from './queryPlanSerializer';
5
- export {
6
- astSerializer,
7
- selectionSetSerializer,
8
- typeSerializer,
9
- queryPlanSerializer,
10
- };
11
-
12
- declare global {
13
- namespace jest {
14
- interface Expect {
15
- /**
16
- * Adds a module to format application-specific data structures for serialization.
17
- */
18
- addSnapshotSerializer(serializer: import('pretty-format').Plugin): void;
19
- }
20
- }
21
- }
@@ -1,144 +0,0 @@
1
- import { Config, Plugin, Refs } from 'pretty-format';
2
- import { PlanNode, QueryPlan } from '../QueryPlan';
3
-
4
- export default {
5
- test(value: any) {
6
- return value && value.kind === 'QueryPlan';
7
- },
8
-
9
- serialize(
10
- queryPlan: QueryPlan,
11
- config: Config,
12
- indentation: string,
13
- depth: number,
14
- refs: Refs,
15
- printer: any,
16
- ): string {
17
- return (
18
- 'QueryPlan {' +
19
- printNodes(
20
- queryPlan.node ? [queryPlan.node] : undefined,
21
- config,
22
- indentation,
23
- depth,
24
- refs,
25
- printer,
26
- ) +
27
- '}'
28
- );
29
- },
30
- } as Plugin;
31
-
32
- function printNode(
33
- node: PlanNode,
34
- config: Config,
35
- indentation: string,
36
- depth: number,
37
- refs: Refs,
38
- printer: any,
39
- ): string {
40
- let result = '';
41
-
42
- const indentationNext = indentation + config.indent;
43
-
44
- switch (node.kind) {
45
- case 'Fetch':
46
- result +=
47
- `Fetch(service: "${node.serviceName}")` +
48
- ' {' +
49
- config.spacingOuter +
50
- indentationNext +
51
- (node.requires
52
- ? printer(
53
- node.requires,
54
- config,
55
- indentationNext,
56
- depth,
57
- refs,
58
- printer,
59
- ) +
60
- ' =>' +
61
- config.spacingOuter +
62
- indentationNext
63
- : '') +
64
- printer(
65
- node.selectionSet,
66
- config,
67
- indentationNext,
68
- depth,
69
- refs,
70
- printer,
71
- ) +
72
- config.spacingOuter +
73
- indentation +
74
- (node.internalFragments.size > 0
75
- ? ' ' +
76
- Array.from(node.internalFragments)
77
- .map(fragment =>
78
- printer(
79
- fragment,
80
- config,
81
- indentationNext,
82
- depth,
83
- refs,
84
- printer,
85
- ),
86
- )
87
- .join(`\n${indentationNext}`) +
88
- config.spacingOuter +
89
- indentation
90
- : '') +
91
- '}';
92
- break;
93
- case 'Flatten':
94
- result += `Flatten(path: "${node.path.join('.')}")`;
95
- break;
96
- default:
97
- result += node.kind;
98
- }
99
-
100
- const nodes =
101
- 'nodes' in node ? node.nodes : 'node' in node ? [node.node] : [];
102
-
103
- if (nodes.length > 0) {
104
- result +=
105
- ' {' + printNodes(nodes, config, indentation, depth, refs, printer) + '}';
106
- }
107
-
108
- return result;
109
- }
110
-
111
- function printNodes(
112
- nodes: PlanNode[] | undefined,
113
- config: Config,
114
- indentation: string,
115
- depth: number,
116
- refs: Refs,
117
- printer: any,
118
- ): string {
119
- let result = '';
120
-
121
- if (nodes && nodes.length > 0) {
122
- result += config.spacingOuter;
123
-
124
- const indentationNext = indentation + config.indent;
125
- for (let i = 0; i < nodes.length; i++) {
126
- const node = nodes[i];
127
- if (!node) continue;
128
-
129
- result +=
130
- indentationNext +
131
- printNode(node, config, indentationNext, depth, refs, printer);
132
-
133
- if (i < nodes.length - 1) {
134
- result += ',' + config.spacingInner;
135
- } else if (!config.min) {
136
- result += ',';
137
- }
138
- }
139
-
140
- result += config.spacingOuter + indentation;
141
- }
142
-
143
- return result;
144
- }
@@ -1,13 +0,0 @@
1
- import { print, SelectionNode, isSelectionNode } from 'graphql';
2
- import { Plugin } from 'pretty-format';
3
-
4
- export default {
5
- test(value: any) {
6
- return (
7
- Array.isArray(value) && value.length > 0 && value.every(isSelectionNode)
8
- );
9
- },
10
- print(selectionNodes: SelectionNode[]): string {
11
- return selectionNodes.map(node => print(node)).join('\n');
12
- },
13
- } as Plugin;
@@ -1,11 +0,0 @@
1
- import { isNamedType, GraphQLNamedType, printType } from 'graphql';
2
- import { Plugin } from 'pretty-format';
3
-
4
- export default {
5
- test(value: any) {
6
- return value && isNamedType(value);
7
- },
8
- print(value: GraphQLNamedType) {
9
- return printType(value);
10
- },
11
- } as Plugin;
@@ -1,11 +0,0 @@
1
- export class MultiMap<K, V> extends Map<K, V[]> {
2
- add(key: K, value: V): this {
3
- let values = this.get(key);
4
- if (values) {
5
- values.push(value);
6
- } else {
7
- this.set(key, (values = [value]));
8
- }
9
- return this;
10
- }
11
- }