@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.
- package/dist/__generated__/graphqlTypes.d.ts +178 -0
- package/dist/__generated__/graphqlTypes.d.ts.map +1 -0
- package/dist/__generated__/graphqlTypes.js +31 -0
- package/dist/__generated__/graphqlTypes.js.map +1 -0
- package/dist/config.d.ts +138 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +60 -0
- package/dist/config.js.map +1 -0
- package/dist/dataRewrites.d.ts +5 -0
- package/dist/dataRewrites.d.ts.map +1 -0
- package/dist/dataRewrites.js +103 -0
- package/dist/dataRewrites.js.map +1 -0
- package/dist/datasources/LocalGraphQLDataSource.d.ts +10 -0
- package/dist/datasources/LocalGraphQLDataSource.d.ts.map +1 -0
- package/dist/datasources/LocalGraphQLDataSource.js +31 -0
- package/dist/datasources/LocalGraphQLDataSource.js.map +1 -0
- package/dist/datasources/RemoteGraphQLDataSource.d.ts +24 -0
- package/dist/datasources/RemoteGraphQLDataSource.d.ts.map +1 -0
- package/dist/datasources/RemoteGraphQLDataSource.js +180 -0
- package/dist/datasources/RemoteGraphQLDataSource.js.map +1 -0
- package/dist/datasources/index.d.ts +4 -0
- package/dist/datasources/index.d.ts.map +1 -0
- package/dist/datasources/index.js +8 -0
- package/dist/datasources/index.js.map +1 -0
- 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 +23 -0
- package/dist/datasources/types.d.ts.map +1 -0
- package/dist/datasources/types.js +10 -0
- package/dist/datasources/types.js.map +1 -0
- package/dist/executeQueryPlan.d.ts +15 -0
- package/dist/executeQueryPlan.d.ts.map +1 -0
- package/dist/executeQueryPlan.js +539 -0
- package/dist/executeQueryPlan.js.map +1 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +590 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +15 -0
- package/dist/logger.js.map +1 -0
- package/dist/operationContext.d.ts +17 -0
- package/dist/operationContext.d.ts.map +1 -0
- package/dist/operationContext.js +38 -0
- package/dist/operationContext.js.map +1 -0
- package/dist/resultShaping.d.ts +12 -0
- package/dist/resultShaping.d.ts.map +1 -0
- package/dist/resultShaping.js +229 -0
- package/dist/resultShaping.js.map +1 -0
- package/dist/schema-helper/addExtensions.d.ts +3 -0
- package/dist/schema-helper/addExtensions.d.ts.map +1 -0
- package/dist/schema-helper/addExtensions.js +23 -0
- package/dist/schema-helper/addExtensions.js.map +1 -0
- package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts +31 -0
- package/dist/supergraphManagers/IntrospectAndCompose/index.d.ts.map +1 -0
- package/dist/supergraphManagers/IntrospectAndCompose/index.js +112 -0
- package/dist/supergraphManagers/IntrospectAndCompose/index.js.map +1 -0
- package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.d.ts +12 -0
- package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.d.ts.map +1 -0
- package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.js +57 -0
- package/dist/supergraphManagers/IntrospectAndCompose/loadServicesFromRemoteEndpoint.js.map +1 -0
- package/dist/supergraphManagers/LegacyFetcher/index.d.ts +33 -0
- package/dist/supergraphManagers/LegacyFetcher/index.d.ts.map +1 -0
- package/dist/supergraphManagers/LegacyFetcher/index.js +149 -0
- package/dist/supergraphManagers/LegacyFetcher/index.js.map +1 -0
- package/dist/supergraphManagers/LocalCompose/index.d.ts +19 -0
- package/dist/supergraphManagers/LocalCompose/index.d.ts.map +1 -0
- package/dist/supergraphManagers/LocalCompose/index.js +55 -0
- package/dist/supergraphManagers/LocalCompose/index.js.map +1 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/index.d.ts +63 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/index.d.ts.map +1 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/index.js +210 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/index.js.map +1 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts +30 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.d.ts.map +1 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.js +145 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/loadSupergraphSdlFromStorage.js.map +1 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.d.ts +14 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.d.ts.map +1 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.js +85 -0
- package/dist/supergraphManagers/UplinkSupergraphManager/outOfBandReporter.js.map +1 -0
- package/dist/supergraphManagers/index.d.ts +6 -0
- package/dist/supergraphManagers/index.d.ts.map +1 -0
- package/dist/supergraphManagers/index.js +27 -0
- package/dist/supergraphManagers/index.js.map +1 -0
- package/dist/typings/graphql.d.ts +11 -0
- package/dist/typings/graphql.d.ts.map +1 -0
- package/dist/typings/graphql.js +3 -0
- package/dist/typings/graphql.js.map +1 -0
- package/dist/utilities/array.d.ts +5 -0
- package/dist/utilities/array.d.ts.map +1 -0
- package/dist/utilities/array.js +46 -0
- package/dist/utilities/array.js.map +1 -0
- 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/deepMerge.d.ts +2 -0
- package/dist/utilities/deepMerge.d.ts.map +1 -0
- package/dist/utilities/deepMerge.js +34 -0
- package/dist/utilities/deepMerge.js.map +1 -0
- package/dist/utilities/graphql.d.ts +5 -0
- package/dist/utilities/graphql.d.ts.map +1 -0
- package/dist/utilities/graphql.js +28 -0
- package/dist/utilities/graphql.js.map +1 -0
- 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/dist/utilities/predicates.d.ts +2 -0
- package/dist/utilities/predicates.d.ts.map +1 -0
- package/dist/utilities/predicates.js +11 -0
- package/dist/utilities/predicates.js.map +1 -0
- 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
|
@@ -53,6 +53,8 @@ export enum FetchErrorCode {
|
|
|
53
53
|
AccessDenied = 'ACCESS_DENIED',
|
|
54
54
|
/** This token provided is not a valid graph token. Do not retry. */
|
|
55
55
|
AuthenticationFailed = 'AUTHENTICATION_FAILED',
|
|
56
|
+
/** This instance of Uplink does not support this feature. Please try another instance. */
|
|
57
|
+
NotImplementedOnThisInstance = 'NOT_IMPLEMENTED_ON_THIS_INSTANCE',
|
|
56
58
|
/** An internal server error occurred. Please retry with some backoff. */
|
|
57
59
|
RetryLater = 'RETRY_LATER',
|
|
58
60
|
/** The graphRef passed is not a valid ref or no configuration for that ref is found. Please retry with some backoff, eg in case of undeletion. */
|
|
@@ -86,16 +88,46 @@ export type MutationReportErrorArgs = {
|
|
|
86
88
|
report?: InputMaybe<ApiMonitoringReport>;
|
|
87
89
|
};
|
|
88
90
|
|
|
91
|
+
/** A chunk of persisted queries */
|
|
92
|
+
export type PersistedQueriesChunk = {
|
|
93
|
+
__typename?: 'PersistedQueriesChunk';
|
|
94
|
+
/** Unique identifier. */
|
|
95
|
+
id: Scalars['ID'];
|
|
96
|
+
/** The chunk can be downloaded from any of those URLs, which might be transient. */
|
|
97
|
+
urls: Array<Scalars['String']>;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type PersistedQueriesResponse = FetchError | PersistedQueriesResult | Unchanged;
|
|
101
|
+
|
|
102
|
+
export type PersistedQueriesResult = {
|
|
103
|
+
__typename?: 'PersistedQueriesResult';
|
|
104
|
+
/** List of URLs chunks are to be fetched from; chunks should be cached by ID between updates. null indicates there is no configured persisted query list. */
|
|
105
|
+
chunks?: Maybe<Array<PersistedQueriesChunk>>;
|
|
106
|
+
/** Unique identifier. */
|
|
107
|
+
id: Scalars['ID'];
|
|
108
|
+
/** Minimum delay before the next fetch should occur, in seconds. */
|
|
109
|
+
minDelaySeconds: Scalars['Float'];
|
|
110
|
+
};
|
|
111
|
+
|
|
89
112
|
export type Query = {
|
|
90
113
|
__typename?: 'Query';
|
|
91
114
|
_empty?: Maybe<Scalars['String']>;
|
|
92
|
-
/** Fetch the
|
|
115
|
+
/** Fetch the persisted queries for a router. */
|
|
116
|
+
persistedQueries: PersistedQueriesResponse;
|
|
117
|
+
/** Fetch the configuration for a router. */
|
|
93
118
|
routerConfig: RouterConfigResponse;
|
|
94
119
|
/** Fetch the current entitlements for a router. */
|
|
95
120
|
routerEntitlements: RouterEntitlementsResponse;
|
|
96
121
|
};
|
|
97
122
|
|
|
98
123
|
|
|
124
|
+
export type QueryPersistedQueriesArgs = {
|
|
125
|
+
apiKey: Scalars['String'];
|
|
126
|
+
ifAfterId?: InputMaybe<Scalars['ID']>;
|
|
127
|
+
ref: Scalars['String'];
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
|
|
99
131
|
export type QueryRouterConfigArgs = {
|
|
100
132
|
apiKey: Scalars['String'];
|
|
101
133
|
ifAfterId?: InputMaybe<Scalars['ID']>;
|
|
@@ -107,7 +139,6 @@ export type QueryRouterEntitlementsArgs = {
|
|
|
107
139
|
apiKey: Scalars['String'];
|
|
108
140
|
ifAfterId?: InputMaybe<Scalars['ID']>;
|
|
109
141
|
ref: Scalars['String'];
|
|
110
|
-
unlessId?: InputMaybe<Scalars['ID']>;
|
|
111
142
|
};
|
|
112
143
|
|
|
113
144
|
export type Request = {
|
package/src/__tests__/.gitkeep
DELETED
|
File without changes
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Query Plan Tests
|
|
2
|
-
|
|
3
|
-
## Introduction
|
|
4
|
-
|
|
5
|
-
There are two files used to test the query plan builder:
|
|
6
|
-
|
|
7
|
-
1. [build-query-plan.feature](./build-query-plan.feature): Programming-language agnostic files written in a format called [Gherkin](https://cucumber.io/docs/gherkin/reference/) for [Cucumber](https://cucumber.io/).
|
|
8
|
-
2. [queryPlanCucumber.test.ts](./queryPlanCucumber.test.ts): The implementation which provides coverage for the Gherkin-specified behavior.
|
|
9
|
-
|
|
10
|
-
> If you're not familiar with Cucumber or BDD, check out [this video](https://youtu.be/lC0jzd8sGIA) for a great introduction to the concepts involved. Cucumber has test runners in multiple languages, allowing a test spec to be written in plain English and then individual implementations of the test suite can describe how they would like tests to be run for their specific implementation. For Java, Kotlin, Ruby, and JavaScript, Cucumber even has a [10-minute tutorial](https://cucumber.io/docs/guides/10-minute-tutorial/) to help get started.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Scenarios
|
|
14
|
-
|
|
15
|
-
_Scenarios_ are Cucumber's test cases. Each scenario should contain the instructions for a single kind of test.
|
|
16
|
-
|
|
17
|
-
## Steps
|
|
18
|
-
|
|
19
|
-
Cucumber tests (scenarios) are made up of `steps`. Each step can be prefixed with a "`Given`", "`When`", or "`Then`" step, which when all provided, must occur in precisely that order. These stages represent test _preconditions_, test _execution_, and test _expectations_, respectively. However, tests don't _need_ all 3 of steps! Scenarios can leave off the `When` step when it's not needed. For example, query plan builder tests only have the "Given" and "Then" steps, like so:
|
|
20
|
-
|
|
21
|
-
```gherkin
|
|
22
|
-
Scenario: should not confuse union types with overlapping field names
|
|
23
|
-
Given query
|
|
24
|
-
"""
|
|
25
|
-
query {
|
|
26
|
-
body {
|
|
27
|
-
...on Image {
|
|
28
|
-
attributes {
|
|
29
|
-
url
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
...on Text {
|
|
33
|
-
attributes {
|
|
34
|
-
bold
|
|
35
|
-
text
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
"""
|
|
41
|
-
Then query plan
|
|
42
|
-
"""
|
|
43
|
-
{
|
|
44
|
-
"kind": "QueryPlan",
|
|
45
|
-
"node": {
|
|
46
|
-
"kind": "Fetch",
|
|
47
|
-
"serviceName": "documents",
|
|
48
|
-
"variableUsages": [],
|
|
49
|
-
"operation": "{body{__typename ...on Image{attributes{url}}...on Text{attributes{bold text}}}}"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
"""
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
There can be multiple of any kind of step using the `And` keyword. In the following example, there are 2 `Given` steps. One represented by the `Given` keyword itself, and another represented with the `And` keyword.
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
Given schema A
|
|
59
|
-
And schema extension B
|
|
60
|
-
Then composed schema should be ...
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Using `And` is especially useful in `Then` steps for testing multiple kinds of expectations. For example, to create a test that looked at a query plan and expected that it called service A and _didn't_ call service B, the test spec would look like this:
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
Given service A, B
|
|
67
|
-
When querying
|
|
68
|
-
"""
|
|
69
|
-
query { a }
|
|
70
|
-
"""
|
|
71
|
-
Then calls service A
|
|
72
|
-
And doesn't call service B
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Writing test integrations
|
|
76
|
-
|
|
77
|
-
Cucumber has a test runner for [many different languages](https://cucumber.io/docs/tools/related-tools/) and test frameworks including Java, Ruby, Rust, and many more. Usually, writing an integration for Cucumber looks similar though. You typically need to write instructions for what to with each kind of step. For example, in the example above where querying a service and expecting things of the query plan, we'd need to define 4 different kind of steps, typically with regex matchers (which are simplified here a bit):
|
|
78
|
-
|
|
79
|
-
1. `^service *`
|
|
80
|
-
2. `^querying`
|
|
81
|
-
3. `^calls *`
|
|
82
|
-
4. `^doesn't call *`
|
|
83
|
-
|
|
84
|
-
Using regex groups, we can extract whatever data we need from the test instructions. For the first pattern, we can use regex to get the service names we want to compose from the given list, and compose them based off a predetermined set of fixtures.
|
|
85
|
-
|
|
86
|
-
Gherkin (the language Cucumber tests are written in) has the idea of [arguments](https://cucumber.io/docs/gherkin/reference/#step-arguments) as well, which is what is used in the second step (the `querying...`) step. The query `query { a }` is referred to as an argument to that step, and each cucumber runner has a way of handling arguments, usually as an argument to the handling function.
|
|
87
|
-
|
|
88
|
-
In JavaScript, writing a function to handle the `querying` step would look something like this:
|
|
89
|
-
|
|
90
|
-
```JavaScript
|
|
91
|
-
when(/^querying$/im, (operation) => {
|
|
92
|
-
result = execute(services, { query: gql(operation) });
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
It's common in Cucumber execution to keep arguments, variables, and other data globally available to each step. This is either done by a variable scoped above the execution of the steps like in the JavaScript example above or as a mutable "context" passed to each step executor function. This just depends on the language you're working with. The reason this pattern is used is that all steps often need similar data. For example, the `querying` step we defined above needs to know what services are being composed from the `Given` step above to actually execute the operation, and the `Then` steps to follow need to access the execution's result data.
|