@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.
- package/dist/__generated__/graphqlTypes.d.ts +19 -1
- package/dist/__generated__/graphqlTypes.d.ts.map +1 -1
- package/dist/__generated__/graphqlTypes.js +1 -0
- package/dist/__generated__/graphqlTypes.js.map +1 -1
- package/package.json +4 -4
- package/src/__generated__/graphqlTypes.ts +33 -2
- package/src/__mocks__/tsconfig.json +0 -7
- package/src/__tests__/.gitkeep +0 -0
- package/src/__tests__/CucumberREADME.md +0 -96
- package/src/__tests__/build-query-plan.feature +0 -1471
- package/src/__tests__/buildQueryPlan.test.ts +0 -1225
- package/src/__tests__/executeQueryPlan.conditions.test.ts +0 -1488
- package/src/__tests__/executeQueryPlan.introspection.test.ts +0 -140
- package/src/__tests__/executeQueryPlan.test.ts +0 -6140
- package/src/__tests__/execution-utils.ts +0 -124
- package/src/__tests__/gateway/__snapshots__/opentelemetry.test.ts.snap +0 -195
- package/src/__tests__/gateway/buildService.test.ts +0 -249
- package/src/__tests__/gateway/endToEnd.test.ts +0 -486
- package/src/__tests__/gateway/executor.test.ts +0 -96
- package/src/__tests__/gateway/extensions.test.ts +0 -37
- package/src/__tests__/gateway/lifecycle-hooks.test.ts +0 -239
- package/src/__tests__/gateway/opentelemetry.test.ts +0 -123
- package/src/__tests__/gateway/queryPlanCache.test.ts +0 -231
- package/src/__tests__/gateway/queryPlannerConfig.test.ts +0 -101
- package/src/__tests__/gateway/reporting.test.ts +0 -616
- package/src/__tests__/gateway/supergraphSdl.test.ts +0 -396
- package/src/__tests__/gateway/testUtils.ts +0 -89
- package/src/__tests__/integration/abstract-types.test.ts +0 -1861
- package/src/__tests__/integration/aliases.test.ts +0 -180
- package/src/__tests__/integration/boolean.test.ts +0 -279
- package/src/__tests__/integration/complex-key.test.ts +0 -197
- package/src/__tests__/integration/configuration.test.ts +0 -404
- package/src/__tests__/integration/custom-directives.test.ts +0 -174
- package/src/__tests__/integration/execution-style.test.ts +0 -35
- package/src/__tests__/integration/fragments.test.ts +0 -237
- package/src/__tests__/integration/list-key.test.ts +0 -128
- package/src/__tests__/integration/logger.test.ts +0 -122
- package/src/__tests__/integration/managed.test.ts +0 -319
- package/src/__tests__/integration/merge-arrays.test.ts +0 -34
- package/src/__tests__/integration/multiple-key.test.ts +0 -327
- package/src/__tests__/integration/mutations.test.ts +0 -287
- package/src/__tests__/integration/networkRequests.test.ts +0 -542
- package/src/__tests__/integration/nockMocks.ts +0 -157
- package/src/__tests__/integration/provides.test.ts +0 -77
- package/src/__tests__/integration/requires.test.ts +0 -359
- package/src/__tests__/integration/scope.test.ts +0 -557
- package/src/__tests__/integration/single-service.test.ts +0 -119
- package/src/__tests__/integration/unions.test.ts +0 -79
- package/src/__tests__/integration/value-types.test.ts +0 -382
- package/src/__tests__/integration/variables.test.ts +0 -120
- package/src/__tests__/nockAssertions.ts +0 -20
- package/src/__tests__/queryPlanCucumber.test.ts +0 -55
- package/src/__tests__/resultShaping.test.ts +0 -605
- package/src/__tests__/testSetup.ts +0 -1
- package/src/__tests__/tsconfig.json +0 -8
- package/src/core/__tests__/core.test.ts +0 -412
- package/src/datasources/__tests__/LocalGraphQLDataSource.test.ts +0 -51
- package/src/datasources/__tests__/RemoteGraphQLDataSource.test.ts +0 -574
- package/src/schema-helper/__tests__/addExtensions.test.ts +0 -70
- package/src/supergraphManagers/IntrospectAndCompose/__tests__/IntrospectAndCompose.test.ts +0 -364
- package/src/supergraphManagers/IntrospectAndCompose/__tests__/loadServicesFromRemoteEndpoint.test.ts +0 -40
- package/src/supergraphManagers/UplinkSupergraphManager/__tests__/UplinkSupergraphManager.test.ts +0 -65
- package/src/supergraphManagers/UplinkSupergraphManager/__tests__/loadSupergraphSdlFromStorage.test.ts +0 -511
- package/src/utilities/__tests__/deepMerge.test.ts +0 -77
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag';
|
|
2
|
-
import { getFederatedTestingSchema, ServiceDefinitionModule } from './execution-utils';
|
|
3
|
-
import { Operation, parseOperation, Schema } from "@apollo/federation-internals";
|
|
4
|
-
import { QueryPlan } from '@apollo/query-planner';
|
|
5
|
-
import { LocalGraphQLDataSource } from '../datasources';
|
|
6
|
-
import { GatewayExecutionResult, GatewayGraphQLRequestContext } from '@apollo/server-gateway-interface';
|
|
7
|
-
import { buildOperationContext } from '../operationContext';
|
|
8
|
-
import { executeQueryPlan } from '../executeQueryPlan';
|
|
9
|
-
|
|
10
|
-
function buildRequestContext(variables: Record<string, any>): GatewayGraphQLRequestContext {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
return {
|
|
14
|
-
cache: undefined as any,
|
|
15
|
-
context: {},
|
|
16
|
-
request: {
|
|
17
|
-
variables,
|
|
18
|
-
},
|
|
19
|
-
metrics: {},
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function executePlan(
|
|
24
|
-
queryPlan: QueryPlan,
|
|
25
|
-
operation: Operation,
|
|
26
|
-
schema: Schema,
|
|
27
|
-
serviceMap: { [serviceName: string]: LocalGraphQLDataSource },
|
|
28
|
-
variables: Record<string, any> = {},
|
|
29
|
-
): Promise<GatewayExecutionResult> {
|
|
30
|
-
const apiSchema = schema.toAPISchema();
|
|
31
|
-
const operationContext = buildOperationContext({
|
|
32
|
-
schema: apiSchema.toGraphQLJSSchema(),
|
|
33
|
-
operationDocument: gql`${operation.toString()}`,
|
|
34
|
-
});
|
|
35
|
-
return executeQueryPlan(
|
|
36
|
-
queryPlan,
|
|
37
|
-
serviceMap,
|
|
38
|
-
buildRequestContext(variables),
|
|
39
|
-
operationContext,
|
|
40
|
-
schema.toGraphQLJSSchema(),
|
|
41
|
-
apiSchema,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
describe('handling of introspection queries', () => {
|
|
46
|
-
const typeDefs: ServiceDefinitionModule[] = [
|
|
47
|
-
{
|
|
48
|
-
name: 'S1',
|
|
49
|
-
typeDefs: gql`
|
|
50
|
-
type Query {
|
|
51
|
-
t: [T]
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface T {
|
|
55
|
-
id: ID!
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type T1 implements T @key(fields: "id") {
|
|
59
|
-
id: ID!
|
|
60
|
-
a1: Int
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type T2 implements T @key(fields: "id") {
|
|
64
|
-
id: ID!
|
|
65
|
-
a2: Int
|
|
66
|
-
}
|
|
67
|
-
`,
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
const { serviceMap, schema, queryPlanner} = getFederatedTestingSchema(typeDefs);
|
|
71
|
-
|
|
72
|
-
it('it handles aliases on introspection fields', async () => {
|
|
73
|
-
const operation = parseOperation(schema, `
|
|
74
|
-
{
|
|
75
|
-
myAlias: __type(name: "T1") {
|
|
76
|
-
kind
|
|
77
|
-
name
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
`);
|
|
81
|
-
|
|
82
|
-
const queryPlan = queryPlanner.buildQueryPlan(operation);
|
|
83
|
-
const response = await executePlan(queryPlan, operation, schema, serviceMap);
|
|
84
|
-
expect(response.errors).toBeUndefined();
|
|
85
|
-
expect(response.data).toMatchInlineSnapshot(`
|
|
86
|
-
Object {
|
|
87
|
-
"myAlias": Object {
|
|
88
|
-
"kind": "OBJECT",
|
|
89
|
-
"name": "T1",
|
|
90
|
-
},
|
|
91
|
-
}
|
|
92
|
-
`);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('it handles aliases inside introspection fields', async () => {
|
|
96
|
-
const operation = parseOperation(schema, `
|
|
97
|
-
{
|
|
98
|
-
__type(name: "T1") {
|
|
99
|
-
myKind: kind
|
|
100
|
-
name
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
`);
|
|
104
|
-
|
|
105
|
-
const queryPlan = queryPlanner.buildQueryPlan(operation);
|
|
106
|
-
const response = await executePlan(queryPlan, operation, schema, serviceMap);
|
|
107
|
-
expect(response.errors).toBeUndefined();
|
|
108
|
-
expect(response.data).toMatchInlineSnapshot(`
|
|
109
|
-
Object {
|
|
110
|
-
"__type": Object {
|
|
111
|
-
"myKind": "OBJECT",
|
|
112
|
-
"name": "T1",
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
`);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('it handles variables passed to introspection fields', async () => {
|
|
119
|
-
const operation = parseOperation(schema, `
|
|
120
|
-
query ($name: String!) {
|
|
121
|
-
__type(name: $name) {
|
|
122
|
-
kind
|
|
123
|
-
name
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
`);
|
|
127
|
-
|
|
128
|
-
const queryPlan = queryPlanner.buildQueryPlan(operation);
|
|
129
|
-
const response = await executePlan(queryPlan, operation, schema, serviceMap, { name: "T1" });
|
|
130
|
-
expect(response.errors).toBeUndefined();
|
|
131
|
-
expect(response.data).toMatchInlineSnapshot(`
|
|
132
|
-
Object {
|
|
133
|
-
"__type": Object {
|
|
134
|
-
"kind": "OBJECT",
|
|
135
|
-
"name": "T1",
|
|
136
|
-
},
|
|
137
|
-
}
|
|
138
|
-
`);
|
|
139
|
-
});
|
|
140
|
-
});
|