@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.
Files changed (68) hide show
  1. package/dist/argumentCompositionStrategies.d.ts +17 -0
  2. package/dist/argumentCompositionStrategies.d.ts.map +1 -1
  3. package/dist/argumentCompositionStrategies.js +38 -0
  4. package/dist/argumentCompositionStrategies.js.map +1 -1
  5. package/dist/error.d.ts +19 -0
  6. package/dist/error.d.ts.map +1 -1
  7. package/dist/error.js +38 -0
  8. package/dist/error.js.map +1 -1
  9. package/dist/extractSubgraphsFromSupergraph.d.ts.map +1 -1
  10. package/dist/extractSubgraphsFromSupergraph.js +59 -8
  11. package/dist/extractSubgraphsFromSupergraph.js.map +1 -1
  12. package/dist/federation.d.ts +9 -2
  13. package/dist/federation.d.ts.map +1 -1
  14. package/dist/federation.js +42 -5
  15. package/dist/federation.js.map +1 -1
  16. package/dist/index.d.ts +2 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +2 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/knownCoreFeatures.d.ts +3 -0
  21. package/dist/knownCoreFeatures.d.ts.map +1 -1
  22. package/dist/knownCoreFeatures.js +12 -1
  23. package/dist/knownCoreFeatures.js.map +1 -1
  24. package/dist/operations.d.ts +3 -1
  25. package/dist/operations.d.ts.map +1 -1
  26. package/dist/operations.js +26 -5
  27. package/dist/operations.js.map +1 -1
  28. package/dist/schemaUpgrader.d.ts.map +1 -1
  29. package/dist/schemaUpgrader.js +50 -31
  30. package/dist/schemaUpgrader.js.map +1 -1
  31. package/dist/specs/coreSpec.d.ts +2 -0
  32. package/dist/specs/coreSpec.d.ts.map +1 -1
  33. package/dist/specs/coreSpec.js +21 -0
  34. package/dist/specs/coreSpec.js.map +1 -1
  35. package/dist/specs/costSpec.d.ts +17 -0
  36. package/dist/specs/costSpec.d.ts.map +1 -0
  37. package/dist/specs/costSpec.js +49 -0
  38. package/dist/specs/costSpec.js.map +1 -0
  39. package/dist/specs/federationSpec.d.ts +6 -1
  40. package/dist/specs/federationSpec.d.ts.map +1 -1
  41. package/dist/specs/federationSpec.js +15 -1
  42. package/dist/specs/federationSpec.js.map +1 -1
  43. package/dist/specs/sourceSpec.d.ts +69 -0
  44. package/dist/specs/sourceSpec.d.ts.map +1 -0
  45. package/dist/specs/sourceSpec.js +345 -0
  46. package/dist/specs/sourceSpec.js.map +1 -0
  47. package/dist/supergraphs.d.ts.map +1 -1
  48. package/dist/supergraphs.js +1 -0
  49. package/dist/supergraphs.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/argumentCompositionStrategies.ts +37 -0
  52. package/src/error.ts +137 -4
  53. package/src/extractSubgraphsFromSupergraph.ts +94 -7
  54. package/src/federation.ts +89 -33
  55. package/src/index.ts +2 -1
  56. package/src/knownCoreFeatures.ts +15 -0
  57. package/src/operations.ts +41 -4
  58. package/src/schemaUpgrader.ts +55 -31
  59. package/src/specs/coreSpec.ts +26 -0
  60. package/src/specs/costSpec.ts +60 -0
  61. package/src/specs/federationSpec.ts +17 -1
  62. package/src/specs/sourceSpec.ts +607 -0
  63. package/src/supergraphs.ts +1 -0
  64. package/dist/specs/connectSpec.d.ts +0 -42
  65. package/dist/specs/connectSpec.d.ts.map +0 -1
  66. package/dist/specs/connectSpec.js +0 -83
  67. package/dist/specs/connectSpec.js.map +0 -1
  68. 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);