@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.
- package/LICENSE +95 -0
- package/README.md +1 -1
- package/dist/__generated__/graphqlTypes.d.ts +130 -0
- package/dist/__generated__/graphqlTypes.d.ts.map +1 -0
- package/dist/__generated__/graphqlTypes.js +25 -0
- package/dist/__generated__/graphqlTypes.js.map +1 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +47 -0
- package/dist/config.js.map +1 -0
- package/dist/datasources/LocalGraphQLDataSource.d.ts +3 -3
- package/dist/datasources/LocalGraphQLDataSource.d.ts.map +1 -1
- package/dist/datasources/LocalGraphQLDataSource.js +5 -5
- package/dist/datasources/LocalGraphQLDataSource.js.map +1 -1
- package/dist/datasources/RemoteGraphQLDataSource.d.ts +6 -4
- package/dist/datasources/RemoteGraphQLDataSource.d.ts.map +1 -1
- package/dist/datasources/RemoteGraphQLDataSource.js +60 -17
- package/dist/datasources/RemoteGraphQLDataSource.js.map +1 -1
- package/dist/datasources/index.d.ts +1 -1
- package/dist/datasources/index.d.ts.map +1 -1
- package/dist/datasources/index.js +1 -0
- package/dist/datasources/index.js.map +1 -1
- package/dist/datasources/parseCacheControlHeader.d.ts +2 -0
- package/dist/datasources/parseCacheControlHeader.d.ts.map +1 -0
- package/dist/datasources/parseCacheControlHeader.js +16 -0
- package/dist/datasources/parseCacheControlHeader.js.map +1 -0
- package/dist/datasources/types.d.ts +16 -1
- package/dist/datasources/types.d.ts.map +1 -1
- package/dist/datasources/types.js +7 -0
- package/dist/datasources/types.js.map +1 -1
- package/dist/executeQueryPlan.d.ts +2 -1
- package/dist/executeQueryPlan.d.ts.map +1 -1
- package/dist/executeQueryPlan.js +199 -112
- package/dist/executeQueryPlan.js.map +1 -1
- package/dist/index.d.ts +62 -80
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +543 -234
- package/dist/index.js.map +1 -1
- package/dist/loadServicesFromRemoteEndpoint.d.ts +9 -9
- package/dist/loadServicesFromRemoteEndpoint.d.ts.map +1 -1
- package/dist/loadServicesFromRemoteEndpoint.js +13 -8
- package/dist/loadServicesFromRemoteEndpoint.js.map +1 -1
- package/dist/loadSupergraphSdlFromStorage.d.ts +13 -0
- package/dist/loadSupergraphSdlFromStorage.d.ts.map +1 -0
- package/dist/loadSupergraphSdlFromStorage.js +101 -0
- package/dist/loadSupergraphSdlFromStorage.js.map +1 -0
- package/dist/operationContext.d.ts +17 -0
- package/dist/operationContext.d.ts.map +1 -0
- package/dist/operationContext.js +42 -0
- package/dist/operationContext.js.map +1 -0
- package/dist/outOfBandReporter.d.ts +15 -0
- package/dist/outOfBandReporter.d.ts.map +1 -0
- package/dist/outOfBandReporter.js +88 -0
- package/dist/outOfBandReporter.js.map +1 -0
- package/dist/utilities/array.d.ts +1 -2
- package/dist/utilities/array.d.ts.map +1 -1
- package/dist/utilities/array.js +7 -14
- package/dist/utilities/array.js.map +1 -1
- package/dist/utilities/assert.d.ts +2 -0
- package/dist/utilities/assert.d.ts.map +1 -0
- package/dist/utilities/assert.js +10 -0
- package/dist/utilities/assert.js.map +1 -0
- package/dist/utilities/cleanErrorOfInaccessibleNames.d.ts +3 -0
- package/dist/utilities/cleanErrorOfInaccessibleNames.d.ts.map +1 -0
- package/dist/utilities/cleanErrorOfInaccessibleNames.js +27 -0
- package/dist/utilities/cleanErrorOfInaccessibleNames.js.map +1 -0
- package/dist/utilities/deepMerge.js +2 -2
- package/dist/utilities/deepMerge.js.map +1 -1
- package/dist/utilities/graphql.d.ts +1 -4
- package/dist/utilities/graphql.d.ts.map +1 -1
- package/dist/utilities/graphql.js +3 -36
- package/dist/utilities/graphql.js.map +1 -1
- package/dist/utilities/opentelemetry.d.ts +10 -0
- package/dist/utilities/opentelemetry.d.ts.map +1 -0
- package/dist/utilities/opentelemetry.js +19 -0
- package/dist/utilities/opentelemetry.js.map +1 -0
- package/package.json +30 -21
- package/src/__generated__/graphqlTypes.ts +140 -0
- package/src/__mocks__/apollo-server-env.ts +56 -0
- package/src/__mocks__/make-fetch-happen-fetcher.ts +55 -0
- package/src/__mocks__/tsconfig.json +7 -0
- package/src/__tests__/build-query-plan.feature +40 -311
- package/src/__tests__/buildQueryPlan.test.ts +246 -426
- package/src/__tests__/executeQueryPlan.test.ts +1691 -194
- package/src/__tests__/execution-utils.ts +33 -26
- package/src/__tests__/gateway/__snapshots__/opentelemetry.test.ts.snap +195 -0
- package/src/__tests__/gateway/buildService.test.ts +16 -19
- package/src/__tests__/gateway/composedSdl.test.ts +44 -0
- package/src/__tests__/gateway/endToEnd.test.ts +166 -0
- package/src/__tests__/gateway/executor.test.ts +49 -43
- package/src/__tests__/gateway/lifecycle-hooks.test.ts +58 -29
- package/src/__tests__/gateway/opentelemetry.test.ts +123 -0
- package/src/__tests__/gateway/queryPlanCache.test.ts +19 -20
- package/src/__tests__/gateway/reporting.test.ts +76 -55
- package/src/__tests__/integration/abstract-types.test.ts +1086 -22
- package/src/__tests__/integration/aliases.test.ts +5 -6
- package/src/__tests__/integration/boolean.test.ts +40 -38
- package/src/__tests__/integration/complex-key.test.ts +41 -56
- package/src/__tests__/integration/configuration.test.ts +321 -0
- package/src/__tests__/integration/custom-directives.test.ts +61 -46
- package/src/__tests__/integration/fragments.test.ts +8 -2
- package/src/__tests__/integration/list-key.test.ts +2 -2
- package/src/__tests__/integration/logger.test.ts +2 -2
- package/src/__tests__/integration/multiple-key.test.ts +11 -12
- package/src/__tests__/integration/mutations.test.ts +8 -5
- package/src/__tests__/integration/networkRequests.test.ts +447 -289
- package/src/__tests__/integration/nockMocks.ts +95 -66
- package/src/__tests__/integration/provides.test.ts +9 -6
- package/src/__tests__/integration/requires.test.ts +17 -15
- package/src/__tests__/integration/scope.test.ts +557 -0
- package/src/__tests__/integration/unions.test.ts +1 -1
- package/src/__tests__/integration/value-types.test.ts +35 -32
- package/src/__tests__/integration/variables.test.ts +8 -2
- package/src/__tests__/loadServicesFromRemoteEndpoint.test.ts +6 -2
- package/src/__tests__/loadSupergraphSdlFromStorage.test.ts +694 -0
- package/src/__tests__/queryPlanCucumber.test.ts +11 -61
- package/src/__tests__/testSetup.ts +1 -4
- package/src/__tests__/tsconfig.json +2 -1
- package/src/config.ts +225 -0
- package/src/core/__tests__/core.test.ts +412 -0
- package/src/datasources/LocalGraphQLDataSource.ts +9 -10
- package/src/datasources/RemoteGraphQLDataSource.ts +117 -43
- package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +11 -4
- package/src/datasources/__tests__/RemoteGraphQLDataSource.test.ts +148 -79
- package/src/datasources/__tests__/tsconfig.json +4 -2
- package/src/datasources/index.ts +1 -1
- package/src/datasources/parseCacheControlHeader.ts +43 -0
- package/src/datasources/types.ts +47 -2
- package/src/executeQueryPlan.ts +264 -153
- package/src/index.ts +925 -480
- package/src/loadServicesFromRemoteEndpoint.ts +24 -17
- package/src/loadSupergraphSdlFromStorage.ts +140 -0
- package/src/make-fetch-happen.d.ts +2 -2
- package/src/operationContext.ts +70 -0
- package/src/outOfBandReporter.ts +128 -0
- package/src/utilities/__tests__/cleanErrorOfInaccessibleElements.test.ts +104 -0
- package/src/utilities/__tests__/tsconfig.json +8 -0
- package/src/utilities/array.ts +6 -28
- package/src/utilities/assert.ts +14 -0
- package/src/utilities/cleanErrorOfInaccessibleNames.ts +29 -0
- package/src/utilities/graphql.ts +0 -64
- package/src/utilities/opentelemetry.ts +13 -0
- package/CHANGELOG.md +0 -226
- package/LICENSE.md +0 -20
- package/dist/FieldSet.d.ts +0 -18
- package/dist/FieldSet.d.ts.map +0 -1
- package/dist/FieldSet.js +0 -96
- package/dist/FieldSet.js.map +0 -1
- package/dist/QueryPlan.d.ts +0 -41
- package/dist/QueryPlan.d.ts.map +0 -1
- package/dist/QueryPlan.js +0 -15
- package/dist/QueryPlan.js.map +0 -1
- package/dist/buildQueryPlan.d.ts +0 -44
- package/dist/buildQueryPlan.d.ts.map +0 -1
- package/dist/buildQueryPlan.js +0 -670
- package/dist/buildQueryPlan.js.map +0 -1
- package/dist/loadServicesFromStorage.d.ts +0 -21
- package/dist/loadServicesFromStorage.d.ts.map +0 -1
- package/dist/loadServicesFromStorage.js +0 -64
- package/dist/loadServicesFromStorage.js.map +0 -1
- package/dist/snapshotSerializers/astSerializer.d.ts +0 -3
- package/dist/snapshotSerializers/astSerializer.d.ts.map +0 -1
- package/dist/snapshotSerializers/astSerializer.js +0 -14
- package/dist/snapshotSerializers/astSerializer.js.map +0 -1
- package/dist/snapshotSerializers/index.d.ts +0 -13
- package/dist/snapshotSerializers/index.d.ts.map +0 -1
- package/dist/snapshotSerializers/index.js +0 -15
- package/dist/snapshotSerializers/index.js.map +0 -1
- package/dist/snapshotSerializers/queryPlanSerializer.d.ts +0 -3
- package/dist/snapshotSerializers/queryPlanSerializer.d.ts.map +0 -1
- package/dist/snapshotSerializers/queryPlanSerializer.js +0 -78
- package/dist/snapshotSerializers/queryPlanSerializer.js.map +0 -1
- package/dist/snapshotSerializers/selectionSetSerializer.d.ts +0 -3
- package/dist/snapshotSerializers/selectionSetSerializer.d.ts.map +0 -1
- package/dist/snapshotSerializers/selectionSetSerializer.js +0 -12
- package/dist/snapshotSerializers/selectionSetSerializer.js.map +0 -1
- package/dist/snapshotSerializers/typeSerializer.d.ts +0 -3
- package/dist/snapshotSerializers/typeSerializer.d.ts.map +0 -1
- package/dist/snapshotSerializers/typeSerializer.js +0 -12
- package/dist/snapshotSerializers/typeSerializer.js.map +0 -1
- package/dist/utilities/MultiMap.d.ts +0 -4
- package/dist/utilities/MultiMap.d.ts.map +0 -1
- package/dist/utilities/MultiMap.js +0 -17
- package/dist/utilities/MultiMap.js.map +0 -1
- package/src/FieldSet.ts +0 -169
- package/src/QueryPlan.ts +0 -57
- package/src/__tests__/matchers/toCallService.ts +0 -105
- package/src/__tests__/matchers/toHaveBeenCalledBefore.ts +0 -40
- package/src/__tests__/matchers/toHaveFetched.ts +0 -81
- package/src/__tests__/matchers/toMatchAST.ts +0 -64
- package/src/buildQueryPlan.ts +0 -1190
- package/src/loadServicesFromStorage.ts +0 -170
- package/src/snapshotSerializers/astSerializer.ts +0 -21
- package/src/snapshotSerializers/index.ts +0 -21
- package/src/snapshotSerializers/queryPlanSerializer.ts +0 -144
- package/src/snapshotSerializers/selectionSetSerializer.ts +0 -13
- package/src/snapshotSerializers/typeSerializer.ts +0 -11
- package/src/utilities/MultiMap.ts +0 -11
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import nock from 'nock';
|
|
2
|
-
import { HEALTH_CHECK_QUERY, SERVICE_DEFINITION_QUERY } from '../..';
|
|
3
2
|
import { MockService } from './networkRequests.test';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { HEALTH_CHECK_QUERY, SERVICE_DEFINITION_QUERY } from '../..';
|
|
4
|
+
import { SUPERGRAPH_SDL_QUERY } from '../../loadSupergraphSdlFromStorage';
|
|
5
|
+
import { getTestingSupergraphSdl } from '../../__tests__/execution-utils';
|
|
6
|
+
import { print } from 'graphql';
|
|
7
|
+
import { fixtures } from 'apollo-federation-integration-testsuite';
|
|
8
|
+
|
|
9
|
+
export const graphRef = 'federated-service@current';
|
|
10
|
+
export const apiKey = 'service:federated-service:DD71EBbGmsuh-6suUVDwnA';
|
|
11
|
+
const apiKeyHash = 'dd55a79d467976346d229a7b12b673ce';
|
|
12
|
+
|
|
13
|
+
export const mockApolloConfig = {
|
|
14
|
+
apollo: {
|
|
15
|
+
key: apiKey,
|
|
16
|
+
keyHash: apiKeyHash,
|
|
17
|
+
graphRef,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
9
20
|
|
|
10
21
|
// Service mocks
|
|
11
|
-
function
|
|
22
|
+
function mockSdlQuery({ url }: MockService) {
|
|
12
23
|
return nock(url).post('/', {
|
|
13
24
|
query: SERVICE_DEFINITION_QUERY,
|
|
14
25
|
});
|
|
15
26
|
}
|
|
16
27
|
|
|
17
|
-
export function
|
|
18
|
-
|
|
19
|
-
data: { _service: { sdl: service.
|
|
28
|
+
export function mockSdlQuerySuccess(service: MockService) {
|
|
29
|
+
return mockSdlQuery(service).reply(200, {
|
|
30
|
+
data: { _service: { sdl: print(service.typeDefs) } },
|
|
20
31
|
});
|
|
21
32
|
}
|
|
22
33
|
|
|
@@ -32,82 +43,100 @@ export function mockServiceHealthCheckSuccess(service: MockService) {
|
|
|
32
43
|
});
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
export function mockAllServicesHealthCheckSuccess() {
|
|
47
|
+
return fixtures.map((fixture) =>
|
|
48
|
+
mockServiceHealthCheck(fixture).reply(200, {
|
|
49
|
+
data: { __typename: 'Query' },
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Supergraph SDL fetching mocks
|
|
55
|
+
function gatewayNock(url: Parameters<typeof nock>[0]): nock.Scope {
|
|
56
|
+
const { name, version } = require('../../../package.json');
|
|
37
57
|
return nock(url, {
|
|
38
58
|
reqheaders: {
|
|
39
|
-
'
|
|
40
|
-
|
|
41
|
-
}`,
|
|
59
|
+
'apollographql-client-name': name,
|
|
60
|
+
'apollographql-client-version': version,
|
|
61
|
+
'user-agent': `${name}/${version}`,
|
|
62
|
+
'content-type': 'application/json',
|
|
42
63
|
},
|
|
43
64
|
});
|
|
44
65
|
}
|
|
45
66
|
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
`/${graphId}/storage-secret/${apiKeyHash}.json`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
67
|
+
export const mockCloudConfigUrl =
|
|
68
|
+
'https://example.cloud-config-url.com/cloudconfig/';
|
|
51
69
|
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
.get(
|
|
55
|
-
`/${graphId}/storage-secret/${apiKeyHash}.json`,
|
|
56
|
-
)
|
|
57
|
-
.reply(200, `"${storageSecret}"`);
|
|
58
|
-
}
|
|
70
|
+
export const mockOutOfBandReporterUrl =
|
|
71
|
+
'https://example.outofbandreporter.com/monitoring/';
|
|
59
72
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return mockCompositionConfigLink().reply(200, {
|
|
69
|
-
configPath: `${storageSecret}/current/v1/composition-configs/composition-config-path.json`,
|
|
73
|
+
export function mockSupergraphSdlRequestIfAfter(ifAfter: string | null) {
|
|
74
|
+
return gatewayNock(mockCloudConfigUrl).post('/', {
|
|
75
|
+
query: SUPERGRAPH_SDL_QUERY,
|
|
76
|
+
variables: {
|
|
77
|
+
ref: graphRef,
|
|
78
|
+
apiKey: apiKey,
|
|
79
|
+
ifAfterId: ifAfter,
|
|
80
|
+
},
|
|
70
81
|
});
|
|
71
82
|
}
|
|
72
83
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return gcsNock('https://federation.api.apollographql.com:443').get(
|
|
76
|
-
`/${storageSecret}/current/v1/composition-configs/composition-config-path.json`,
|
|
77
|
-
);
|
|
84
|
+
export function mockSupergraphSdlRequest(ifAfter: string | null = null) {
|
|
85
|
+
return mockSupergraphSdlRequestIfAfter(ifAfter);
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
export function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
export function mockSupergraphSdlRequestSuccessIfAfter(
|
|
89
|
+
ifAfter: string | null = null,
|
|
90
|
+
id: string = 'originalId-1234',
|
|
91
|
+
supergraphSdl: string = getTestingSupergraphSdl(),
|
|
92
|
+
) {
|
|
93
|
+
if (supergraphSdl == null) {
|
|
94
|
+
supergraphSdl = getTestingSupergraphSdl();
|
|
95
|
+
}
|
|
96
|
+
return mockSupergraphSdlRequestIfAfter(ifAfter).reply(
|
|
97
|
+
200,
|
|
98
|
+
JSON.stringify({
|
|
99
|
+
data: {
|
|
100
|
+
routerConfig: {
|
|
101
|
+
__typename: 'RouterConfigResult',
|
|
102
|
+
id,
|
|
103
|
+
supergraphSdl,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
87
108
|
}
|
|
88
109
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
110
|
+
export function mockSupergraphSdlRequestIfAfterUnchanged(
|
|
111
|
+
ifAfter: string | null = null,
|
|
112
|
+
) {
|
|
113
|
+
return mockSupergraphSdlRequestIfAfter(ifAfter).reply(
|
|
114
|
+
200,
|
|
115
|
+
JSON.stringify({
|
|
116
|
+
data: {
|
|
117
|
+
routerConfig: {
|
|
118
|
+
__typename: 'Unchanged',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
93
122
|
);
|
|
94
123
|
}
|
|
95
124
|
|
|
96
|
-
export function
|
|
97
|
-
return
|
|
98
|
-
name: accountsService,
|
|
99
|
-
partialSchemaPath: `${storageSecret}/current/raw-partial-schemas/${service.partialSchemaPath}`,
|
|
100
|
-
url: service.url,
|
|
101
|
-
});
|
|
125
|
+
export function mockSupergraphSdlRequestSuccess() {
|
|
126
|
+
return mockSupergraphSdlRequestSuccessIfAfter(null);
|
|
102
127
|
}
|
|
103
128
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return gcsNock('https://federation.api.apollographql.com:443').get(
|
|
107
|
-
`/${storageSecret}/current/raw-partial-schemas/${partialSchemaPath}`,
|
|
108
|
-
);
|
|
129
|
+
export function mockOutOfBandReportRequest() {
|
|
130
|
+
return gatewayNock(mockOutOfBandReporterUrl).post('/', () => true);
|
|
109
131
|
}
|
|
110
132
|
|
|
111
|
-
export function
|
|
112
|
-
return
|
|
133
|
+
export function mockOutOfBandReportRequestSuccess() {
|
|
134
|
+
return mockOutOfBandReportRequest().reply(
|
|
135
|
+
200,
|
|
136
|
+
JSON.stringify({
|
|
137
|
+
data: {
|
|
138
|
+
reportError: true
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
113
142
|
}
|
|
@@ -45,7 +45,10 @@ it('does not load fields provided even when going to other service', async () =>
|
|
|
45
45
|
topReviews {
|
|
46
46
|
author {
|
|
47
47
|
username
|
|
48
|
-
name
|
|
48
|
+
name {
|
|
49
|
+
first
|
|
50
|
+
last
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -60,11 +63,11 @@ it('does not load fields provided even when going to other service', async () =>
|
|
|
60
63
|
|
|
61
64
|
expect(data).toEqual({
|
|
62
65
|
topReviews: [
|
|
63
|
-
{ author: { username: '@ada', name: 'Ada Lovelace' } },
|
|
64
|
-
{ author: { username: '@ada', name: 'Ada Lovelace' } },
|
|
65
|
-
{ author: { username: '@complete', name: 'Alan Turing' } },
|
|
66
|
-
{ author: { username: '@complete', name: 'Alan Turing' } },
|
|
67
|
-
{ author: { username: '@complete', name: 'Alan Turing' } },
|
|
66
|
+
{ author: { username: '@ada', name: { first: 'Ada', last: 'Lovelace' } } },
|
|
67
|
+
{ author: { username: '@ada', name: { first: 'Ada', last: 'Lovelace' } } },
|
|
68
|
+
{ author: { username: '@complete', name: { first: 'Alan', last: 'Turing' } } },
|
|
69
|
+
{ author: { username: '@complete', name: { first: 'Alan', last: 'Turing' } } },
|
|
70
|
+
{ author: { username: '@complete', name: { first: 'Alan', last: 'Turing' } } },
|
|
68
71
|
],
|
|
69
72
|
});
|
|
70
73
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { execute } from '../execution-utils';
|
|
3
|
-
import {
|
|
3
|
+
import { astSerializer, queryPlanSerializer } from 'apollo-federation-integration-testsuite';
|
|
4
4
|
|
|
5
|
+
expect.addSnapshotSerializer(astSerializer);
|
|
6
|
+
expect.addSnapshotSerializer(queryPlanSerializer);
|
|
5
7
|
it('supports passing additional fields defined by a requires', async () => {
|
|
6
8
|
const query = `#graphql
|
|
7
9
|
query GetReviwedBookNames {
|
|
@@ -128,33 +130,33 @@ it('collapses nested requires', async () => {
|
|
|
128
130
|
|
|
129
131
|
expect(errors).toEqual(undefined);
|
|
130
132
|
|
|
131
|
-
expect(
|
|
132
|
-
|
|
133
|
+
expect(queryPlan).toMatchInlineSnapshot(`
|
|
134
|
+
QueryPlan {
|
|
133
135
|
Sequence {
|
|
134
|
-
Fetch(service:
|
|
136
|
+
Fetch(service: "a") {
|
|
135
137
|
{
|
|
136
138
|
user {
|
|
137
139
|
__typename
|
|
138
140
|
id
|
|
139
141
|
preferences {
|
|
140
142
|
favorites {
|
|
141
|
-
color
|
|
142
143
|
animal
|
|
144
|
+
color
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
},
|
|
148
|
-
Flatten(path:
|
|
149
|
-
Fetch(service:
|
|
150
|
+
Flatten(path: "user") {
|
|
151
|
+
Fetch(service: "b") {
|
|
150
152
|
{
|
|
151
153
|
... on User {
|
|
152
154
|
__typename
|
|
153
155
|
id
|
|
154
156
|
preferences {
|
|
155
157
|
favorites {
|
|
156
|
-
color
|
|
157
158
|
animal
|
|
159
|
+
color
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
}
|
|
@@ -168,7 +170,7 @@ it('collapses nested requires', async () => {
|
|
|
168
170
|
},
|
|
169
171
|
},
|
|
170
172
|
},
|
|
171
|
-
}
|
|
173
|
+
}
|
|
172
174
|
`);
|
|
173
175
|
|
|
174
176
|
expect(data).toEqual({
|
|
@@ -209,10 +211,10 @@ it('collapses nested requires with user-defined fragments', async () => {
|
|
|
209
211
|
|
|
210
212
|
expect(errors).toEqual(undefined);
|
|
211
213
|
|
|
212
|
-
expect(
|
|
213
|
-
|
|
214
|
+
expect(queryPlan).toMatchInlineSnapshot(`
|
|
215
|
+
QueryPlan {
|
|
214
216
|
Sequence {
|
|
215
|
-
Fetch(service:
|
|
217
|
+
Fetch(service: "a") {
|
|
216
218
|
{
|
|
217
219
|
user {
|
|
218
220
|
__typename
|
|
@@ -226,8 +228,8 @@ it('collapses nested requires with user-defined fragments', async () => {
|
|
|
226
228
|
}
|
|
227
229
|
}
|
|
228
230
|
},
|
|
229
|
-
Flatten(path:
|
|
230
|
-
Fetch(service:
|
|
231
|
+
Flatten(path: "user") {
|
|
232
|
+
Fetch(service: "b") {
|
|
231
233
|
{
|
|
232
234
|
... on User {
|
|
233
235
|
__typename
|
|
@@ -247,7 +249,7 @@ it('collapses nested requires with user-defined fragments', async () => {
|
|
|
247
249
|
},
|
|
248
250
|
},
|
|
249
251
|
},
|
|
250
|
-
}
|
|
252
|
+
}
|
|
251
253
|
`);
|
|
252
254
|
|
|
253
255
|
expect(data).toEqual({
|