@apollo/federation-internals 2.9.0-connectors.8 → 2.9.0
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/argumentCompositionStrategies.d.ts +17 -0
- package/dist/argumentCompositionStrategies.d.ts.map +1 -1
- package/dist/argumentCompositionStrategies.js +38 -0
- package/dist/argumentCompositionStrategies.js.map +1 -1
- package/dist/error.d.ts +19 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +38 -0
- package/dist/error.js.map +1 -1
- package/dist/extractSubgraphsFromSupergraph.d.ts.map +1 -1
- package/dist/extractSubgraphsFromSupergraph.js +59 -8
- package/dist/extractSubgraphsFromSupergraph.js.map +1 -1
- package/dist/federation.d.ts +9 -2
- package/dist/federation.d.ts.map +1 -1
- package/dist/federation.js +42 -5
- package/dist/federation.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/knownCoreFeatures.d.ts +3 -0
- package/dist/knownCoreFeatures.d.ts.map +1 -1
- package/dist/knownCoreFeatures.js +12 -1
- package/dist/knownCoreFeatures.js.map +1 -1
- package/dist/operations.d.ts +3 -1
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +26 -5
- package/dist/operations.js.map +1 -1
- package/dist/schemaUpgrader.d.ts.map +1 -1
- package/dist/schemaUpgrader.js +50 -31
- package/dist/schemaUpgrader.js.map +1 -1
- package/dist/specs/coreSpec.d.ts +2 -0
- package/dist/specs/coreSpec.d.ts.map +1 -1
- package/dist/specs/coreSpec.js +21 -0
- package/dist/specs/coreSpec.js.map +1 -1
- package/dist/specs/costSpec.d.ts +17 -0
- package/dist/specs/costSpec.d.ts.map +1 -0
- package/dist/specs/costSpec.js +49 -0
- package/dist/specs/costSpec.js.map +1 -0
- package/dist/specs/federationSpec.d.ts +6 -1
- package/dist/specs/federationSpec.d.ts.map +1 -1
- package/dist/specs/federationSpec.js +15 -1
- package/dist/specs/federationSpec.js.map +1 -1
- package/dist/specs/sourceSpec.d.ts +69 -0
- package/dist/specs/sourceSpec.d.ts.map +1 -0
- package/dist/specs/sourceSpec.js +345 -0
- package/dist/specs/sourceSpec.js.map +1 -0
- package/dist/supergraphs.d.ts.map +1 -1
- package/dist/supergraphs.js +1 -0
- package/dist/supergraphs.js.map +1 -1
- package/package.json +1 -1
- package/src/argumentCompositionStrategies.ts +37 -0
- package/src/error.ts +137 -4
- package/src/extractSubgraphsFromSupergraph.ts +94 -7
- package/src/federation.ts +89 -33
- package/src/index.ts +2 -1
- package/src/knownCoreFeatures.ts +15 -0
- package/src/operations.ts +41 -4
- package/src/schemaUpgrader.ts +55 -31
- package/src/specs/coreSpec.ts +26 -0
- package/src/specs/costSpec.ts +60 -0
- package/src/specs/federationSpec.ts +17 -1
- package/src/specs/sourceSpec.ts +607 -0
- package/src/supergraphs.ts +1 -0
- package/dist/specs/connectSpec.d.ts +0 -42
- package/dist/specs/connectSpec.d.ts.map +0 -1
- package/dist/specs/connectSpec.js +0 -83
- package/dist/specs/connectSpec.js.map +0 -1
- package/src/specs/connectSpec.ts +0 -183
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { DirectiveLocation } from 'graphql';
|
|
2
|
+
import { createDirectiveSpecification } from '../directiveAndTypeSpecification';
|
|
3
|
+
import { FeatureDefinition, FeatureDefinitions, FeatureUrl, FeatureVersion } from './coreSpec';
|
|
4
|
+
import { ListType, NonNullType } from '../definitions';
|
|
5
|
+
import { registerKnownFeature } from '../knownCoreFeatures';
|
|
6
|
+
import { ARGUMENT_COMPOSITION_STRATEGIES } from '../argumentCompositionStrategies';
|
|
7
|
+
|
|
8
|
+
export const costIdentity = 'https://specs.apollo.dev/cost';
|
|
9
|
+
|
|
10
|
+
export class CostSpecDefinition extends FeatureDefinition {
|
|
11
|
+
constructor(version: FeatureVersion, readonly minimumFederationVersion: FeatureVersion) {
|
|
12
|
+
super(new FeatureUrl(costIdentity, 'cost', version), minimumFederationVersion);
|
|
13
|
+
|
|
14
|
+
this.registerDirective(createDirectiveSpecification({
|
|
15
|
+
name: 'cost',
|
|
16
|
+
locations: [
|
|
17
|
+
DirectiveLocation.ARGUMENT_DEFINITION,
|
|
18
|
+
DirectiveLocation.ENUM,
|
|
19
|
+
DirectiveLocation.FIELD_DEFINITION,
|
|
20
|
+
DirectiveLocation.INPUT_FIELD_DEFINITION,
|
|
21
|
+
DirectiveLocation.OBJECT,
|
|
22
|
+
DirectiveLocation.SCALAR
|
|
23
|
+
],
|
|
24
|
+
args: [{ name: 'weight', type: (schema) => new NonNullType(schema.intType()), compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.MAX }],
|
|
25
|
+
composes: true,
|
|
26
|
+
repeatable: false,
|
|
27
|
+
supergraphSpecification: (fedVersion) => COST_VERSIONS.getMinimumRequiredVersion(fedVersion),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
this.registerDirective(createDirectiveSpecification({
|
|
31
|
+
name: 'listSize',
|
|
32
|
+
locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
33
|
+
args: [
|
|
34
|
+
{ name: 'assumedSize', type: (schema) => schema.intType(), compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.NULLABLE_MAX },
|
|
35
|
+
{ name: 'slicingArguments', type: (schema) => new ListType(new NonNullType(schema.stringType())), compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.NULLABLE_UNION },
|
|
36
|
+
{ name: 'sizedFields', type: (schema) => new ListType(new NonNullType(schema.stringType())), compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.NULLABLE_UNION },
|
|
37
|
+
{ name: 'requireOneSlicingArgument', type: (schema) => schema.booleanType(), defaultValue: true, compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.NULLABLE_AND },
|
|
38
|
+
],
|
|
39
|
+
composes: true,
|
|
40
|
+
repeatable: false,
|
|
41
|
+
supergraphSpecification: (fedVersion) => COST_VERSIONS.getMinimumRequiredVersion(fedVersion)
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const COST_VERSIONS = new FeatureDefinitions<CostSpecDefinition>(costIdentity)
|
|
47
|
+
.add(new CostSpecDefinition(new FeatureVersion(0, 1), new FeatureVersion(2, 9)));
|
|
48
|
+
|
|
49
|
+
registerKnownFeature(COST_VERSIONS);
|
|
50
|
+
|
|
51
|
+
export interface CostDirectiveArguments {
|
|
52
|
+
weight: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ListSizeDirectiveArguments {
|
|
56
|
+
assumedSize?: number;
|
|
57
|
+
slicingArguments?: string[];
|
|
58
|
+
sizedFields?: string[];
|
|
59
|
+
requireOneSlicingArgument?: boolean;
|
|
60
|
+
}
|
|
@@ -18,7 +18,9 @@ import { INACCESSIBLE_VERSIONS } from "./inaccessibleSpec";
|
|
|
18
18
|
import { AUTHENTICATED_VERSIONS } from "./authenticatedSpec";
|
|
19
19
|
import { REQUIRES_SCOPES_VERSIONS } from "./requiresScopesSpec";
|
|
20
20
|
import { POLICY_VERSIONS } from './policySpec';
|
|
21
|
+
import { SOURCE_VERSIONS } from './sourceSpec';
|
|
21
22
|
import { CONTEXT_VERSIONS } from './contextSpec';
|
|
23
|
+
import { COST_VERSIONS } from "./costSpec";
|
|
22
24
|
|
|
23
25
|
export const federationIdentity = 'https://specs.apollo.dev/federation';
|
|
24
26
|
|
|
@@ -42,8 +44,13 @@ export enum FederationDirectiveName {
|
|
|
42
44
|
AUTHENTICATED = 'authenticated',
|
|
43
45
|
REQUIRES_SCOPES = 'requiresScopes',
|
|
44
46
|
POLICY = 'policy',
|
|
47
|
+
SOURCE_API = 'sourceAPI',
|
|
48
|
+
SOURCE_TYPE = 'sourceType',
|
|
49
|
+
SOURCE_FIELD = 'sourceField',
|
|
45
50
|
CONTEXT = 'context',
|
|
46
51
|
FROM_CONTEXT = 'fromContext',
|
|
52
|
+
COST = 'cost',
|
|
53
|
+
LIST_SIZE = 'listSize',
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
const fieldSetTypeSpec = createScalarTypeSpecification({ name: FederationTypeName.FIELD_SET });
|
|
@@ -171,9 +178,17 @@ export class FederationSpecDefinition extends FeatureDefinition {
|
|
|
171
178
|
this.registerSubFeature(POLICY_VERSIONS.find(new FeatureVersion(0, 1))!);
|
|
172
179
|
}
|
|
173
180
|
|
|
181
|
+
if (version.gte(new FeatureVersion(2, 7))) {
|
|
182
|
+
this.registerSubFeature(SOURCE_VERSIONS.find(new FeatureVersion(0, 1))!);
|
|
183
|
+
}
|
|
184
|
+
|
|
174
185
|
if (version.gte(new FeatureVersion(2, 8))) {
|
|
175
186
|
this.registerSubFeature(CONTEXT_VERSIONS.find(new FeatureVersion(0, 1))!);
|
|
176
187
|
}
|
|
188
|
+
|
|
189
|
+
if (version.gte(new FeatureVersion(2, 9))) {
|
|
190
|
+
this.registerSubFeature(COST_VERSIONS.find(new FeatureVersion(0, 1))!);
|
|
191
|
+
}
|
|
177
192
|
}
|
|
178
193
|
}
|
|
179
194
|
|
|
@@ -186,6 +201,7 @@ export const FEDERATION_VERSIONS = new FeatureDefinitions<FederationSpecDefiniti
|
|
|
186
201
|
.add(new FederationSpecDefinition(new FeatureVersion(2, 5)))
|
|
187
202
|
.add(new FederationSpecDefinition(new FeatureVersion(2, 6)))
|
|
188
203
|
.add(new FederationSpecDefinition(new FeatureVersion(2, 7)))
|
|
189
|
-
.add(new FederationSpecDefinition(new FeatureVersion(2, 8)))
|
|
204
|
+
.add(new FederationSpecDefinition(new FeatureVersion(2, 8)))
|
|
205
|
+
.add(new FederationSpecDefinition(new FeatureVersion(2, 9)));
|
|
190
206
|
|
|
191
207
|
registerKnownFeature(FEDERATION_VERSIONS);
|