@apollo/federation-internals 2.8.3 → 2.9.0-beta.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/extractSubgraphsFromSupergraph.d.ts.map +1 -1
- package/dist/extractSubgraphsFromSupergraph.js +59 -8
- package/dist/extractSubgraphsFromSupergraph.js.map +1 -1
- package/dist/federation.d.ts +5 -2
- package/dist/federation.d.ts.map +1 -1
- package/dist/federation.js +16 -2
- package/dist/federation.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.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 +1 -0
- package/dist/specs/coreSpec.d.ts.map +1 -1
- package/dist/specs/coreSpec.js +18 -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 +3 -1
- package/dist/specs/federationSpec.d.ts.map +1 -1
- package/dist/specs/federationSpec.js +8 -1
- package/dist/specs/federationSpec.js.map +1 -1
- 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/extractSubgraphsFromSupergraph.ts +94 -7
- package/src/federation.ts +21 -2
- package/src/index.ts +1 -0
- package/src/operations.ts +41 -4
- package/src/schemaUpgrader.ts +55 -31
- package/src/specs/coreSpec.ts +21 -0
- package/src/specs/costSpec.ts +60 -0
- package/src/specs/federationSpec.ts +9 -1
- package/src/supergraphs.ts +1 -0
|
@@ -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
|
+
}
|
|
@@ -20,6 +20,7 @@ import { REQUIRES_SCOPES_VERSIONS } from "./requiresScopesSpec";
|
|
|
20
20
|
import { POLICY_VERSIONS } from './policySpec';
|
|
21
21
|
import { SOURCE_VERSIONS } from './sourceSpec';
|
|
22
22
|
import { CONTEXT_VERSIONS } from './contextSpec';
|
|
23
|
+
import { COST_VERSIONS } from "./costSpec";
|
|
23
24
|
|
|
24
25
|
export const federationIdentity = 'https://specs.apollo.dev/federation';
|
|
25
26
|
|
|
@@ -48,6 +49,8 @@ export enum FederationDirectiveName {
|
|
|
48
49
|
SOURCE_FIELD = 'sourceField',
|
|
49
50
|
CONTEXT = 'context',
|
|
50
51
|
FROM_CONTEXT = 'fromContext',
|
|
52
|
+
COST = 'cost',
|
|
53
|
+
LIST_SIZE = 'listSize',
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
const fieldSetTypeSpec = createScalarTypeSpecification({ name: FederationTypeName.FIELD_SET });
|
|
@@ -182,6 +185,10 @@ export class FederationSpecDefinition extends FeatureDefinition {
|
|
|
182
185
|
if (version.gte(new FeatureVersion(2, 8))) {
|
|
183
186
|
this.registerSubFeature(CONTEXT_VERSIONS.find(new FeatureVersion(0, 1))!);
|
|
184
187
|
}
|
|
188
|
+
|
|
189
|
+
if (version.gte(new FeatureVersion(2, 9))) {
|
|
190
|
+
this.registerSubFeature(COST_VERSIONS.find(new FeatureVersion(0, 1))!);
|
|
191
|
+
}
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
|
|
@@ -194,6 +201,7 @@ export const FEDERATION_VERSIONS = new FeatureDefinitions<FederationSpecDefiniti
|
|
|
194
201
|
.add(new FederationSpecDefinition(new FeatureVersion(2, 5)))
|
|
195
202
|
.add(new FederationSpecDefinition(new FeatureVersion(2, 6)))
|
|
196
203
|
.add(new FederationSpecDefinition(new FeatureVersion(2, 7)))
|
|
197
|
-
.add(new FederationSpecDefinition(new FeatureVersion(2, 8)))
|
|
204
|
+
.add(new FederationSpecDefinition(new FeatureVersion(2, 8)))
|
|
205
|
+
.add(new FederationSpecDefinition(new FeatureVersion(2, 9)));
|
|
198
206
|
|
|
199
207
|
registerKnownFeature(FEDERATION_VERSIONS);
|
package/src/supergraphs.ts
CHANGED
|
@@ -40,6 +40,7 @@ export const ROUTER_SUPPORTED_SUPERGRAPH_FEATURES = new Set([
|
|
|
40
40
|
'https://specs.apollo.dev/policy/v0.1',
|
|
41
41
|
'https://specs.apollo.dev/source/v0.1',
|
|
42
42
|
'https://specs.apollo.dev/context/v0.1',
|
|
43
|
+
'https://specs.apollo.dev/cost/v0.1',
|
|
43
44
|
]);
|
|
44
45
|
|
|
45
46
|
const coreVersionZeroDotOneUrl = FeatureUrl.parse('https://specs.apollo.dev/core/v0.1');
|