@apollo/federation-internals 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/Subgraph.d.ts +1 -0
- package/dist/Subgraph.d.ts.map +1 -0
- package/dist/Subgraph.js +2 -0
- package/dist/Subgraph.js.map +1 -0
- package/dist/argumentCompositionStrategies.d.ts +34 -0
- package/dist/argumentCompositionStrategies.d.ts.map +1 -0
- package/dist/argumentCompositionStrategies.js +35 -0
- package/dist/argumentCompositionStrategies.js.map +1 -0
- package/dist/buildSchema.d.ts +10 -0
- package/dist/buildSchema.d.ts.map +1 -0
- package/dist/buildSchema.js +362 -0
- package/dist/buildSchema.js.map +1 -0
- package/dist/coreSpec.d.ts +127 -0
- package/dist/coreSpec.d.ts.map +1 -0
- package/dist/coreSpec.js +590 -0
- package/dist/coreSpec.js.map +1 -0
- package/dist/debug.d.ts +15 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +122 -0
- package/dist/debug.js.map +1 -0
- package/dist/definitions.d.ts +663 -0
- package/dist/definitions.d.ts.map +1 -0
- package/dist/definitions.js +2841 -0
- package/dist/definitions.js.map +1 -0
- package/dist/directiveAndTypeSpecification.d.ts +67 -0
- package/dist/directiveAndTypeSpecification.d.ts.map +1 -0
- package/dist/directiveAndTypeSpecification.js +271 -0
- package/dist/directiveAndTypeSpecification.js.map +1 -0
- package/dist/error.d.ts +128 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +315 -0
- package/dist/error.js.map +1 -0
- package/dist/extractSubgraphsFromSupergraph.d.ts +8 -0
- package/dist/extractSubgraphsFromSupergraph.d.ts.map +1 -0
- package/dist/extractSubgraphsFromSupergraph.js +576 -0
- package/dist/extractSubgraphsFromSupergraph.js.map +1 -0
- package/dist/federation.d.ts +175 -0
- package/dist/federation.d.ts.map +1 -0
- package/dist/federation.js +1414 -0
- package/dist/federation.js.map +1 -0
- package/dist/federationSpec.d.ts +25 -0
- package/dist/federationSpec.d.ts.map +1 -0
- package/dist/federationSpec.js +125 -0
- package/dist/federationSpec.js.map +1 -0
- package/dist/genErrorCodeDoc.d.ts +2 -0
- package/dist/genErrorCodeDoc.d.ts.map +1 -0
- package/dist/genErrorCodeDoc.js +61 -0
- package/dist/genErrorCodeDoc.js.map +1 -0
- package/dist/graphQLJSSchemaToAST.d.ts +8 -0
- package/dist/graphQLJSSchemaToAST.d.ts.map +1 -0
- package/dist/graphQLJSSchemaToAST.js +96 -0
- package/dist/graphQLJSSchemaToAST.js.map +1 -0
- package/dist/inaccessibleSpec.d.ts +18 -0
- package/dist/inaccessibleSpec.d.ts.map +1 -0
- package/dist/inaccessibleSpec.js +655 -0
- package/dist/inaccessibleSpec.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/introspection.d.ts +6 -0
- package/dist/introspection.d.ts.map +1 -0
- package/dist/introspection.js +96 -0
- package/dist/introspection.js.map +1 -0
- package/dist/joinSpec.d.ts +51 -0
- package/dist/joinSpec.d.ts.map +1 -0
- package/dist/joinSpec.js +160 -0
- package/dist/joinSpec.js.map +1 -0
- package/dist/knownCoreFeatures.d.ts +5 -0
- package/dist/knownCoreFeatures.d.ts.map +1 -0
- package/dist/knownCoreFeatures.js +20 -0
- package/dist/knownCoreFeatures.js.map +1 -0
- package/dist/operations.d.ts +418 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +2068 -0
- package/dist/operations.js.map +1 -0
- package/dist/precompute.d.ts +3 -0
- package/dist/precompute.d.ts.map +1 -0
- package/dist/precompute.js +54 -0
- package/dist/precompute.js.map +1 -0
- package/dist/print.d.ts +28 -0
- package/dist/print.d.ts.map +1 -0
- package/dist/print.js +299 -0
- package/dist/print.js.map +1 -0
- package/dist/schemaUpgrader.d.ts +121 -0
- package/dist/schemaUpgrader.d.ts.map +1 -0
- package/dist/schemaUpgrader.js +570 -0
- package/dist/schemaUpgrader.js.map +1 -0
- package/dist/suggestions.d.ts +3 -0
- package/dist/suggestions.d.ts.map +1 -0
- package/dist/suggestions.js +44 -0
- package/dist/suggestions.js.map +1 -0
- package/dist/supergraphs.d.ts +10 -0
- package/dist/supergraphs.d.ts.map +1 -0
- package/dist/supergraphs.js +76 -0
- package/dist/supergraphs.js.map +1 -0
- package/dist/tagSpec.d.ts +19 -0
- package/dist/tagSpec.d.ts.map +1 -0
- package/dist/tagSpec.js +66 -0
- package/dist/tagSpec.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +64 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +64 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +326 -0
- package/dist/utils.js.map +1 -0
- package/dist/validate.d.ts +4 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +239 -0
- package/dist/validate.js.map +1 -0
- package/dist/validation/KnownTypeNamesInFederationRule.d.ts +4 -0
- package/dist/validation/KnownTypeNamesInFederationRule.d.ts.map +1 -0
- package/dist/validation/KnownTypeNamesInFederationRule.js +41 -0
- package/dist/validation/KnownTypeNamesInFederationRule.js.map +1 -0
- package/dist/values.d.ts +23 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +580 -0
- package/dist/values.js.map +1 -0
- package/package.json +1 -1
- package/src/operations.ts +145 -20
- package/src/utils.ts +1 -1
- package/CHANGELOG.md +0 -205
- package/jest.config.js +0 -11
- package/src/__tests__/coreSpec.test.ts +0 -212
- package/src/__tests__/definitions.test.ts +0 -982
- package/src/__tests__/directiveAndTypeSpecifications.test.ts +0 -41
- package/src/__tests__/extractSubgraphsFromSupergraph.test.ts +0 -748
- package/src/__tests__/federation.test.ts +0 -31
- package/src/__tests__/graphQLJSSchemaToAST.test.ts +0 -156
- package/src/__tests__/matchers/index.ts +0 -1
- package/src/__tests__/matchers/toMatchString.ts +0 -87
- package/src/__tests__/operations.test.ts +0 -1266
- package/src/__tests__/removeInaccessibleElements.test.ts +0 -2471
- package/src/__tests__/schemaUpgrader.test.ts +0 -287
- package/src/__tests__/subgraphValidation.test.ts +0 -1254
- package/src/__tests__/supergraphSdl.graphql +0 -281
- package/src/__tests__/testUtils.ts +0 -28
- package/src/__tests__/toAPISchema.test.ts +0 -53
- package/src/__tests__/tsconfig.json +0 -7
- package/src/__tests__/utils.test.ts +0 -92
- package/src/__tests__/values.test.ts +0 -390
- package/tsconfig.json +0 -10
- package/tsconfig.test.json +0 -8
package/src/operations.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
isLeafType,
|
|
47
47
|
Variables,
|
|
48
48
|
isObjectType,
|
|
49
|
+
NamedType,
|
|
49
50
|
} from "./definitions";
|
|
50
51
|
import { isInterfaceObjectType } from "./federation";
|
|
51
52
|
import { ERRORS } from "./error";
|
|
@@ -152,7 +153,11 @@ export class Field<TArgs extends {[key: string]: any} = {[key: string]: any}> ex
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
isLeafField(): boolean {
|
|
155
|
-
return isLeafType(baseType(
|
|
156
|
+
return isLeafType(this.baseType());
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
baseType(): NamedType {
|
|
160
|
+
return baseType(this.definition.type!);
|
|
156
161
|
}
|
|
157
162
|
|
|
158
163
|
withUpdatedDefinition(newDefinition: FieldDefinition<any>): Field<TArgs> {
|
|
@@ -674,7 +679,7 @@ export function concatOperationPaths(head: OperationPath, tail: OperationPath):
|
|
|
674
679
|
|
|
675
680
|
function isUselessFollowupElement(first: OperationElement, followup: OperationElement, conditionals: Directive<any, any>[]): boolean {
|
|
676
681
|
const typeOfFirst = first.kind === 'Field'
|
|
677
|
-
? baseType(
|
|
682
|
+
? first.baseType()
|
|
678
683
|
: first.typeCondition;
|
|
679
684
|
|
|
680
685
|
// The followup is useless if it's a fragment (with no directives we would want to preserve) whose type
|
|
@@ -1042,7 +1047,6 @@ export class NamedFragments {
|
|
|
1042
1047
|
dependsOn: string[],
|
|
1043
1048
|
};
|
|
1044
1049
|
const fragmentsMap = new Map<string, FragmentInfo>();
|
|
1045
|
-
|
|
1046
1050
|
const removedFragments = new Set<string>();
|
|
1047
1051
|
for (const fragment of this.definitions()) {
|
|
1048
1052
|
const mappedSelectionSet = mapper(fragment.selectionSet.expandAllFragments().trimUnsatisfiableBranches(fragment.typeCondition));
|
|
@@ -1430,7 +1434,73 @@ export class SelectionSet {
|
|
|
1430
1434
|
for (const selection of selections) {
|
|
1431
1435
|
mergedSubselections.add(selection.selectionSet!);
|
|
1432
1436
|
}
|
|
1433
|
-
|
|
1437
|
+
|
|
1438
|
+
// We know all the `selections` are basically for the same element (same field or same inline fragment),
|
|
1439
|
+
// and we want to return a single selection with the merged selections. There is a subtlety regarding
|
|
1440
|
+
// the parent type of that merged selection however: we cannot safely rely on the parent type of any
|
|
1441
|
+
// of the individual selections, because this can be incorrect. Let's illustrate.
|
|
1442
|
+
// Consider that we have:
|
|
1443
|
+
// ```graphql
|
|
1444
|
+
// type Query {
|
|
1445
|
+
// a: A!
|
|
1446
|
+
// }
|
|
1447
|
+
//
|
|
1448
|
+
// interface IA1 {
|
|
1449
|
+
// b: IB1!
|
|
1450
|
+
// }
|
|
1451
|
+
//
|
|
1452
|
+
// interface IA2 {
|
|
1453
|
+
// b: IB2!
|
|
1454
|
+
// }
|
|
1455
|
+
//
|
|
1456
|
+
// type A implements IA1 & IA2 {
|
|
1457
|
+
// b: B!
|
|
1458
|
+
// }
|
|
1459
|
+
//
|
|
1460
|
+
// interface IB1 {
|
|
1461
|
+
// v1: Int!
|
|
1462
|
+
// }
|
|
1463
|
+
//
|
|
1464
|
+
// interface IB2 {
|
|
1465
|
+
// v2: Int!
|
|
1466
|
+
// }
|
|
1467
|
+
//
|
|
1468
|
+
// type B implements IB1 & IB2 {
|
|
1469
|
+
// v1: Int!
|
|
1470
|
+
// v2: Int!
|
|
1471
|
+
// }
|
|
1472
|
+
// ```
|
|
1473
|
+
// and suppose that we're trying to check if selection set:
|
|
1474
|
+
// maybeSuperset = { ... on IA1 { b { v1 } } ... on IA2 { b { v2 } } } // (parent type A)
|
|
1475
|
+
// contains selection set:
|
|
1476
|
+
// maybeSubset = { b { v1 v2 } } // (parent type A)
|
|
1477
|
+
//
|
|
1478
|
+
// In that case, the `contains` method below will call this function with the 2 sub-selections
|
|
1479
|
+
// from `maybeSuperset`, but with the unecessary interface fragment removed (reminder that the
|
|
1480
|
+
// parent type is `A`, so the "casts" into the interfaces are semantically useless).
|
|
1481
|
+
//
|
|
1482
|
+
// And so in that case, the argument to this method will be:
|
|
1483
|
+
// [ b { v1 } (parent type IA1), b { v2 } (parent type IA2) ]
|
|
1484
|
+
// but then, the sub-selection `{ v1 }` of the 1st value will have parent type IB1,
|
|
1485
|
+
// and the sub-selection `{ v2 }` of the 2nd value will have parent type IB2,
|
|
1486
|
+
// neither of which work for the merge sub-selection.
|
|
1487
|
+
//
|
|
1488
|
+
// Instead, we want to use as parent type the type of field `b` the parent type of `this`
|
|
1489
|
+
// (which is `maybeSupeset` in our example). Which means that we want to use type `B` for
|
|
1490
|
+
// the sub-selection, which is now guaranteed to work (or `maybeSupergerset` wouldn't have
|
|
1491
|
+
// been valid).
|
|
1492
|
+
//
|
|
1493
|
+
// Long story short, we get that type by rebasing any of the selection element (we use the
|
|
1494
|
+
// first as we have it) on `this.parentType`, which gives use the element we want, and we
|
|
1495
|
+
// use the type of that for the sub-selection.
|
|
1496
|
+
|
|
1497
|
+
if (first.kind === 'FieldSelection') {
|
|
1498
|
+
const rebasedField = first.element.rebaseOn(this.parentType);
|
|
1499
|
+
return new FieldSelection(rebasedField, mergedSubselections.toSelectionSet(rebasedField.baseType() as CompositeType));
|
|
1500
|
+
} else {
|
|
1501
|
+
const rebasedFragment = first.element.rebaseOn(this.parentType);
|
|
1502
|
+
return new InlineFragmentSelection(rebasedFragment, mergedSubselections.toSelectionSet(rebasedFragment.castedType()));
|
|
1503
|
+
}
|
|
1434
1504
|
}
|
|
1435
1505
|
|
|
1436
1506
|
contains(that: SelectionSet): boolean {
|
|
@@ -1456,6 +1526,28 @@ export class SelectionSet {
|
|
|
1456
1526
|
// validate this (`canApplyAtType` is not free, and we want to avoid repeating it multiple times).
|
|
1457
1527
|
diffWithNamedFragmentIfContained(candidate: NamedFragmentDefinition, parentType: CompositeType): { contains: boolean, diff?: SelectionSet } {
|
|
1458
1528
|
const that = candidate.selectionSetAtType(parentType);
|
|
1529
|
+
// It's possible that while the fragment technically applies at `parentType`, it's "rebasing" on
|
|
1530
|
+
// `parentType` is empty, or contains only `__typename`. For instance, suppose we have
|
|
1531
|
+
// a union `U = A | B | C`, and then a fragment:
|
|
1532
|
+
// ```graphql
|
|
1533
|
+
// fragment F on U {
|
|
1534
|
+
// ... on A {
|
|
1535
|
+
// x
|
|
1536
|
+
// }
|
|
1537
|
+
// ... on b {
|
|
1538
|
+
// y
|
|
1539
|
+
// }
|
|
1540
|
+
// }
|
|
1541
|
+
// ```
|
|
1542
|
+
// It is then possible to apply `F` when the parent type is `C`, but this ends up selecting
|
|
1543
|
+
// nothing at all.
|
|
1544
|
+
//
|
|
1545
|
+
// Returning `contains: true` in those cases is, while not 100% incorrect, at least not productive,
|
|
1546
|
+
// and so we skip right away in that case. This is essentially an optimisation.
|
|
1547
|
+
if (that.isEmpty() || (that.selections().length === 1 && that.selections()[0].isTypenameField())) {
|
|
1548
|
+
return { contains: false };
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1459
1551
|
if (this.contains(that)) {
|
|
1460
1552
|
// One subtlety here is that at "this" sub-selections may already have been optimized with some fragments. It's
|
|
1461
1553
|
// usually ok because `candidate` will also use those fragments, but one fragments that `candidate` can never be
|
|
@@ -1483,6 +1575,17 @@ export class SelectionSet {
|
|
|
1483
1575
|
const otherSelections = that.triviallyNestedSelectionsForKey(this.parentType, key);
|
|
1484
1576
|
const allSelections = thatSelection ? [thatSelection].concat(otherSelections) : otherSelections;
|
|
1485
1577
|
if (allSelections.length === 0) {
|
|
1578
|
+
// If it is a fragment spread, and we didn't find it in `that`, then we try to expand that
|
|
1579
|
+
// fragment and see if that result is entirely covered by `that`. If that is the case, then it means
|
|
1580
|
+
// `thisSelection` does not need to be in the returned "diff". If it's not entirely covered,
|
|
1581
|
+
// we just add the spread itself to the diff: even if some parts of it were covered by `that`,
|
|
1582
|
+
// keeping just the fragment is, in a sense, more condensed.
|
|
1583
|
+
if (thisSelection instanceof FragmentSpreadSelection) {
|
|
1584
|
+
const expanded = thisSelection.selectionSet.expandAllFragments().trimUnsatisfiableBranches(this.parentType);
|
|
1585
|
+
if (expanded.minus(that).isEmpty()) {
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1486
1589
|
updated.add(thisSelection);
|
|
1487
1590
|
} else {
|
|
1488
1591
|
const selectionDiff = allSelections.reduce<Selection | undefined>((prev, val) => prev?.minus(val), thisSelection);
|
|
@@ -1790,7 +1893,7 @@ function makeSelection(parentType: CompositeType, updates: SelectionUpdate[], fr
|
|
|
1790
1893
|
}
|
|
1791
1894
|
|
|
1792
1895
|
const element = updateElement(first).rebaseOn(parentType);
|
|
1793
|
-
const subSelectionParentType = element.kind === 'Field' ? baseType(
|
|
1896
|
+
const subSelectionParentType = element.kind === 'Field' ? element.baseType() : element.castedType();
|
|
1794
1897
|
if (!isCompositeType(subSelectionParentType)) {
|
|
1795
1898
|
// This is a leaf, so all updates should correspond ot the same field and we just use the first.
|
|
1796
1899
|
return selectionOfElement(element);
|
|
@@ -1984,6 +2087,11 @@ abstract class AbstractSelection<TElement extends OperationElement, TIsLeaf exte
|
|
|
1984
2087
|
return this.element.parentType;
|
|
1985
2088
|
}
|
|
1986
2089
|
|
|
2090
|
+
isTypenameField(): boolean {
|
|
2091
|
+
// Overridden where appropriate
|
|
2092
|
+
return false;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
1987
2095
|
collectVariables(collector: VariableCollector) {
|
|
1988
2096
|
this.element.collectVariables(collector);
|
|
1989
2097
|
this.selectionSet?.collectVariables(collector)
|
|
@@ -2110,6 +2218,10 @@ export class FieldSelection extends AbstractSelection<Field<any>, undefined, Fie
|
|
|
2110
2218
|
return this;
|
|
2111
2219
|
}
|
|
2112
2220
|
|
|
2221
|
+
isTypenameField(): boolean {
|
|
2222
|
+
return this.element.definition.name === typenameFieldName;
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2113
2225
|
withUpdatedComponents(field: Field<any>, selectionSet: SelectionSet | undefined): FieldSelection {
|
|
2114
2226
|
return new FieldSelection(field, selectionSet);
|
|
2115
2227
|
}
|
|
@@ -2120,7 +2232,7 @@ export class FieldSelection extends AbstractSelection<Field<any>, undefined, Fie
|
|
|
2120
2232
|
|
|
2121
2233
|
optimize(fragments: NamedFragments): Selection {
|
|
2122
2234
|
let optimizedSelection = this.selectionSet ? this.selectionSet.optimizeSelections(fragments) : undefined;
|
|
2123
|
-
const fieldBaseType =
|
|
2235
|
+
const fieldBaseType = this.element.baseType();
|
|
2124
2236
|
if (isCompositeType(fieldBaseType) && optimizedSelection) {
|
|
2125
2237
|
const optimized = this.tryOptimizeSubselectionWithFragments({
|
|
2126
2238
|
parentType: fieldBaseType,
|
|
@@ -2213,7 +2325,7 @@ export class FieldSelection extends AbstractSelection<Field<any>, undefined, Fie
|
|
|
2213
2325
|
return this.withUpdatedElement(rebasedElement);
|
|
2214
2326
|
}
|
|
2215
2327
|
|
|
2216
|
-
const rebasedBase = baseType(
|
|
2328
|
+
const rebasedBase = rebasedElement.baseType();
|
|
2217
2329
|
if (rebasedBase === this.selectionSet.parentType) {
|
|
2218
2330
|
return this.withUpdatedElement(rebasedElement);
|
|
2219
2331
|
}
|
|
@@ -2279,7 +2391,7 @@ export class FieldSelection extends AbstractSelection<Field<any>, undefined, Fie
|
|
|
2279
2391
|
return this;
|
|
2280
2392
|
}
|
|
2281
2393
|
|
|
2282
|
-
const base =
|
|
2394
|
+
const base = this.element.baseType()
|
|
2283
2395
|
assert(isCompositeType(base), () => `Field ${this.element} should not have a sub-selection`);
|
|
2284
2396
|
const trimmed = (options?.recursive ?? true) ? this.mapToSelectionSet((s) => s.trimUnsatisfiableBranches(base)) : this;
|
|
2285
2397
|
// In rare caes, it's possible that everything in the sub-selection was trimmed away and so the
|
|
@@ -2385,7 +2497,6 @@ export abstract class FragmentSelection extends AbstractSelection<FragmentElemen
|
|
|
2385
2497
|
|| (isObjectType(parentType) && possibleRuntimeTypes(this.element.typeCondition).some((t) => t.name === parentType.name))
|
|
2386
2498
|
);
|
|
2387
2499
|
}
|
|
2388
|
-
|
|
2389
2500
|
}
|
|
2390
2501
|
|
|
2391
2502
|
class InlineFragmentSelection extends FragmentSelection {
|
|
@@ -2597,7 +2708,7 @@ class InlineFragmentSelection extends FragmentSelection {
|
|
|
2597
2708
|
if (isObjectType(thisCondition) || !possibleRuntimeTypes(thisCondition).includes(currentType)) {
|
|
2598
2709
|
return undefined;
|
|
2599
2710
|
} else {
|
|
2600
|
-
const trimmed =this.selectionSet.trimUnsatisfiableBranches(currentType, options);
|
|
2711
|
+
const trimmed = this.selectionSet.trimUnsatisfiableBranches(currentType, options);
|
|
2601
2712
|
return trimmed.isEmpty() ? undefined : trimmed;
|
|
2602
2713
|
}
|
|
2603
2714
|
}
|
|
@@ -2728,8 +2839,10 @@ class FragmentSpreadSelection extends FragmentSelection {
|
|
|
2728
2839
|
assert(false, `Unsupported`);
|
|
2729
2840
|
}
|
|
2730
2841
|
|
|
2731
|
-
trimUnsatisfiableBranches(
|
|
2732
|
-
|
|
2842
|
+
trimUnsatisfiableBranches(parentType: CompositeType): FragmentSelection {
|
|
2843
|
+
// We must update the spread parent type if necessary since we're not going deeper,
|
|
2844
|
+
// or we'll be fundamentally losing context.
|
|
2845
|
+
return this.rebaseOn(parentType);
|
|
2733
2846
|
}
|
|
2734
2847
|
|
|
2735
2848
|
namedFragments(): NamedFragments | undefined {
|
|
@@ -2766,18 +2879,30 @@ class FragmentSpreadSelection extends FragmentSelection {
|
|
|
2766
2879
|
return this;
|
|
2767
2880
|
}
|
|
2768
2881
|
|
|
2769
|
-
rebaseOn(
|
|
2770
|
-
//
|
|
2771
|
-
//
|
|
2772
|
-
// reuse a user fragment). But in practice, we expand all fragments when we do query planning and only re-add
|
|
2773
|
-
// fragments back at the very end, so this should be fine. Importantly, we don't want this method to mistakenly
|
|
2774
|
-
// expand the spread, as that would compromise the code that optimize subgraph fetches to re-use named
|
|
2882
|
+
rebaseOn(parentType: CompositeType): FragmentSelection {
|
|
2883
|
+
// We preserve the parent type here, to make sure we don't lose context, but we actually don't
|
|
2884
|
+
// want to expand the spread as that would compromise the code that optimize subgraph fetches to re-use named
|
|
2775
2885
|
// fragments.
|
|
2776
|
-
|
|
2886
|
+
//
|
|
2887
|
+
// This is a little bit iffy, because the fragment may not apply at this parent type, but we
|
|
2888
|
+
// currently leave it to the caller to ensure this is not a mistake. But most of the
|
|
2889
|
+
// QP code works on selections with fully expanded fragments, so this code (and that of `canAddTo`
|
|
2890
|
+
// on come into play in the code for reusing fragments, and that code calls those methods
|
|
2891
|
+
// appropriately.
|
|
2892
|
+
if (this.parentType === parentType) {
|
|
2893
|
+
return this;
|
|
2894
|
+
}
|
|
2895
|
+
return new FragmentSpreadSelection(
|
|
2896
|
+
parentType,
|
|
2897
|
+
this.fragments,
|
|
2898
|
+
this.namedFragment,
|
|
2899
|
+
this.spreadDirectives,
|
|
2900
|
+
);
|
|
2777
2901
|
}
|
|
2778
2902
|
|
|
2779
2903
|
canAddTo(_: CompositeType): boolean {
|
|
2780
|
-
//
|
|
2904
|
+
// Since `rebaseOn` never fail, we copy the logic here and always return `true`. But as
|
|
2905
|
+
// mentioned in `rebaseOn`, this leave it a bit to the caller to know what he is doing.
|
|
2781
2906
|
return true;
|
|
2782
2907
|
}
|
|
2783
2908
|
|
package/src/utils.ts
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
# CHANGELOG for `@apollo/federation-internals`
|
|
2
|
-
|
|
3
|
-
## 2.4.4
|
|
4
|
-
|
|
5
|
-
## 2.4.3
|
|
6
|
-
### Patch Changes
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- Improves the heuristics used to try to reuse the query named fragments in subgraph fetches. Said fragment will be reused ([#2541](https://github.com/apollographql/federation/pull/2541))
|
|
10
|
-
more often, which can lead to smaller subgraph queries (and hence overall faster processing).
|
|
11
|
-
|
|
12
|
-
## 2.4.2
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- Allow passing print options to the `compose` method to impact how the supergraph is printed, and adds new printing ([#2042](https://github.com/apollographql/federation/pull/2042))
|
|
17
|
-
options to order all elements of the schema.
|
|
18
|
-
|
|
19
|
-
- Fix potential bug when an `@interfaceObject` type has a `@requires`. When an `@interfaceObject` type has a field with a ([#2524](https://github.com/apollographql/federation/pull/2524))
|
|
20
|
-
`@requires` and the query requests that field only for some specific implementations of the corresponding interface,
|
|
21
|
-
then the generated query plan was sometimes invalid and could result in an invalid query to a subgraph (against a
|
|
22
|
-
subgraph that rely on `@apollo/subgraph`, this lead the subgraph to produce an error message looking like `"The
|
|
23
|
-
_entities resolver tried to load an entity for type X, but no object or interface type of that name was found in the
|
|
24
|
-
schema"`).
|
|
25
|
-
|
|
26
|
-
## 2.4.1
|
|
27
|
-
### Patch Changes
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- Fix issues (incorrectly rejected composition and/or subgraph errors) with `@interfaceObject`. Those issues may occur ([#2494](https://github.com/apollographql/federation/pull/2494))
|
|
31
|
-
either due to some use of `@requires` in an `@interfaceObject` type, or when some subgraph `S` defines a type that is an
|
|
32
|
-
implementation of an interface `I` in the supergraph, and there is an `@interfaceObject` for `I` in another subgraph,
|
|
33
|
-
but `S` does not itself defines `I`.
|
|
34
|
-
|
|
35
|
-
- Fix assertion error during query planning in some cases where queries has some unsatisfiable branches (a part of the ([#2486](https://github.com/apollographql/federation/pull/2486))
|
|
36
|
-
query goes through type conditions that no runtime types satisfies).
|
|
37
|
-
|
|
38
|
-
- Start building packages with TS 5.x, which should have no effect on consumers ([#2480](https://github.com/apollographql/federation/pull/2480))
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- Improves reuse of named fragments in subgraph fetches. When a question has named fragments, the code tries to reuse ([#2497](https://github.com/apollographql/federation/pull/2497))
|
|
42
|
-
those fragment in subgraph fetches is those can apply (so when the fragment is fully queried in a single subgraph fetch).
|
|
43
|
-
However, the existing was only able to reuse those fragment in a small subset of cases. This change makes it much more
|
|
44
|
-
likely that _if_ a fragment can be reused, it will be.
|
|
45
|
-
|
|
46
|
-
## 2.4.0
|
|
47
|
-
### Patch Changes
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- Refactor the internal implementation of selection sets used by the query planner to decrease the code complexity and ([#2387](https://github.com/apollographql/federation/pull/2387))
|
|
51
|
-
improve query plan generation performance in many cases.
|
|
52
|
-
|
|
53
|
-
- Revert #2293. Removing URL import causes a problem when running under deno. ([#2451](https://github.com/apollographql/federation/pull/2451))
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- Use globally available URL object instead of node builtin "url" module ([#2293](https://github.com/apollographql/federation/pull/2293))
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- Optimises query plan generation for parts of queries that can statically be known to not cross across subgraphs ([#2449](https://github.com/apollographql/federation/pull/2449))
|
|
60
|
-
|
|
61
|
-
## 2.4.0-alpha.1
|
|
62
|
-
### Patch Changes
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
- Revert #2293. Removing URL import causes a problem when running under deno. ([#2451](https://github.com/apollographql/federation/pull/2451))
|
|
66
|
-
|
|
67
|
-
## 2.4.0-alpha.0
|
|
68
|
-
### Patch Changes
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
- Handle defaulted variables correctly during post-processing. ([#2443](https://github.com/apollographql/federation/pull/2443))
|
|
72
|
-
|
|
73
|
-
Users who tried to use built-in conditional directives (skip/include) with _defaulted_ variables and no variable provided would encounter an error thrown by operation post-processing saying that the variables weren't provided. The defaulted values went unaccounted for, so the operation would validate but then fail an assertion while resolving the conditional.
|
|
74
|
-
|
|
75
|
-
With this change, defaulted variable values are now collected and provided to post-processing (with defaults being overwritten by variables that are actually provided).
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## 2.3.5
|
|
79
|
-
|
|
80
|
-
## 2.3.4
|
|
81
|
-
### Patch Changes
|
|
82
|
-
|
|
83
|
-
- Use globally available URL object instead of node builtin "url" module ([#2293](https://github.com/apollographql/federation/pull/2293))
|
|
84
|
-
|
|
85
|
-
## 2.3.3
|
|
86
|
-
|
|
87
|
-
## 2.3.2
|
|
88
|
-
|
|
89
|
-
## 2.3.1
|
|
90
|
-
|
|
91
|
-
## 2.3.0
|
|
92
|
-
|
|
93
|
-
- Fix incorrect handling of `@external` on a type when dealing when adding `@shareable` during fed1 schema upgrades [PR #2343](https://github.com/apollographql/federation/pull/2343).
|
|
94
|
-
|
|
95
|
-
## 2.2.1
|
|
96
|
-
|
|
97
|
-
- Fix federation spec always being expanded to the last version [PR #2274](https://github.com/apollographql/federation/pull/2274).
|
|
98
|
-
|
|
99
|
-
## 2.2.0
|
|
100
|
-
|
|
101
|
-
- Preserve default values of input object fields [PR #2218](https://github.com/apollographql/federation/pull/2218).
|
|
102
|
-
- Provide support for marking @external on object type [PR #2214](https://github.com/apollographql/federation/pull/2214)
|
|
103
|
-
- Drop support for node12 [PR #2202](https://github.com/apollographql/federation/pull/2202)
|
|
104
|
-
- Correctly reject field names starting with `__` [PR #2237](https://github.com/apollographql/federation/pull/2237).
|
|
105
|
-
- Preserve default values of input object fields [PR #2218](https://github.com/apollographql/federation/pull/2218).
|
|
106
|
-
|
|
107
|
-
## 2.1.4
|
|
108
|
-
|
|
109
|
-
- Ensures supergraph `@defer`/`@stream` definitions of supergraph are not included in the API schema [PR #2212](https://github.com/apollographql/federation/pull/2212).
|
|
110
|
-
- Fix validation of variable on input field not taking default into account [PR #2176](https://github.com/apollographql/federation/pull/2176).
|
|
111
|
-
|
|
112
|
-
## 2.1.0
|
|
113
|
-
|
|
114
|
-
- Update peer dependency `graphql` to `^16.5.0` to use `GraphQLErrorOptions` [PR #2060](https://github.com/apollographql/federation/pull/2060)
|
|
115
|
-
- Don't require `@link` when using `@composeDirective` [PR #2046](https://github.com/apollographql/federation/pull/2046)
|
|
116
|
-
- Add `@defer` support [PR #1958](https://github.com/apollographql/federation/pull/1958)
|
|
117
|
-
- Add `@composeDirective` directive to specify directives that should be merged to the supergraph during composition [PR #1996](https://github.com/apollographql/federation/pull/1996).
|
|
118
|
-
- Expand support for Node.js v18 [PR #1884](https://github.com/apollographql/federation/pull/1884)
|
|
119
|
-
|
|
120
|
-
## 2.0.4
|
|
121
|
-
|
|
122
|
-
- Fix issue when all root operations were defined in an `extend schema` [PR #1875](https://github.com/apollographql/federation/issues/1875).
|
|
123
|
-
|
|
124
|
-
## 2.0.3
|
|
125
|
-
|
|
126
|
-
- Fix bug with type extension of empty type definition [PR #1821](https://github.com/apollographql/federation/pull/1821)
|
|
127
|
-
|
|
128
|
-
## 2.0.2
|
|
129
|
-
|
|
130
|
-
- Fix bug removing an enum type [PR #1813](https://github.com/apollographql/federation/pull/1813)
|
|
131
|
-
- Fix `Schema.clone` when directive application happens before definition [PR #1785](https://github.com/apollographql/federation/pull/1785)
|
|
132
|
-
- More helpful error message for errors encountered while reading supergraphs generated pre-federation 2 [PR #1796](https://github.com/apollographql/federation/pull/1796)
|
|
133
|
-
- Fix bug applying an imported federation directive on another directive definition [PR #1797](https://github.com/apollographql/federation/pull/1797).
|
|
134
|
-
- Prevent non-core-feature elements from being marked @inaccessible if referenced by core feature elements [PR #1769](https://github.com/apollographql/federation/pull/1769)
|
|
135
|
-
- Improve fed1 schema support during composition [PR #1735](https://github.com/apollographql/federation/pull/1735)
|
|
136
|
-
- Honor directive imports when directive name is spec name [PR #1720](https://github.com/apollographql/federation/pull/1720)
|
|
137
|
-
|
|
138
|
-
## v2.0.1
|
|
139
|
-
|
|
140
|
-
- Use `for: SECURITY` in the core/link directive application in the supergraph for `@inaccessible` [PR #1715](https://github.com/apollographql/federation/pull/1715)
|
|
141
|
-
|
|
142
|
-
## v2.0.0
|
|
143
|
-
|
|
144
|
-
- Previous preview release promoted to general availability! Please see previous changelog entries for full info.
|
|
145
|
-
|
|
146
|
-
## v2.0.0-preview.14
|
|
147
|
-
|
|
148
|
-
- Implement `buildSubgraphSchema` using federation internals [PR #1697](https://github.com/apollographql/federation/pull/1697)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
## v2.0.0-preview.11
|
|
152
|
-
|
|
153
|
-
- Add support for `@inaccessible` v0.2 [PR #1678](https://github.com/apollographql/federation/pull/1678)
|
|
154
|
-
- Add a level to hints, uppercase their code and related fixes [PR #1683](https://github.com/apollographql/federation/pull/1683).
|
|
155
|
-
|
|
156
|
-
## v2.0.0-preview.9
|
|
157
|
-
|
|
158
|
-
- Adds Support for `@tag/v0.2`, which allows the `@tag` directive to be additionally placed on arguments, scalars, enums, enum values, input objects, and input object fields. [PR #1652](https://github.com/apollographql/federation/pull/1652).
|
|
159
|
-
- Add missing `includeDeprecated` argument for `args` and `inputFields` when defining introspection fields [PR #1584](https://github.com/apollographql/federation/pull/1584)
|
|
160
|
-
- Adds support for the `@override` directive on fields to indicate that a field should be moved from one subgraph to another. [PR #1484](https://github.com/apollographql/federation/pull/1484)
|
|
161
|
-
|
|
162
|
-
## v2.0.0-preview.5
|
|
163
|
-
|
|
164
|
-
- Fix propagation of `@tag` to the supergraph and allows @tag to be repeated. Additionally, merged directives (only `@tag` and `@deprecated` currently) are not allowed on external fields anymore [PR #1592](https://github.com/apollographql/federation/pull/1592).
|
|
165
|
-
|
|
166
|
-
## v2.0.0-preview.4
|
|
167
|
-
|
|
168
|
-
- Make error messages more actionable when constructing subgraphs from a supergraph [PR #1586](https://github.com/apollographql/federation/pull/1586)
|
|
169
|
-
|
|
170
|
-
## v2.0.0-preview.3
|
|
171
|
-
|
|
172
|
-
- Fix issue that created type extensions with descriptions, which is invalid graphQL syntax [PR #1582](https://github.com/apollographql/federation/pull/1582).
|
|
173
|
-
|
|
174
|
-
## v2.0.0-preview.2
|
|
175
|
-
|
|
176
|
-
- Re-publishing release which published to npm with stale build artifacts from `version-0.x` release.
|
|
177
|
-
|
|
178
|
-
## v2.0.0-preview.1
|
|
179
|
-
|
|
180
|
-
- No-op publish to account for publishing difficulties.
|
|
181
|
-
|
|
182
|
-
## v2.0.0-preview.0
|
|
183
|
-
|
|
184
|
-
- Initial "preview" release.
|
|
185
|
-
|
|
186
|
-
## v2.0.0-alpha.6
|
|
187
|
-
|
|
188
|
-
- Avoid incomplete subgraphs when extracting them from the supergraph. [PR #1511](https://github.com/apollographql/federation/pull/1511)
|
|
189
|
-
|
|
190
|
-
## v2.0.0-alpha.5
|
|
191
|
-
|
|
192
|
-
- Remove `graphql@15` from peer dependencies [PR #1472](https://github.com/apollographql/federation/pull/1472).
|
|
193
|
-
|
|
194
|
-
## v2.0.0-alpha.3
|
|
195
|
-
|
|
196
|
-
- Assign and document error codes for all errors [PR #1274](https://github.com/apollographql/federation/pull/1274).
|
|
197
|
-
- Fix issue reading some 0.x generated supergraphs [PR #1351](https://github.com/apollographql/federation/pull/1351).
|
|
198
|
-
|
|
199
|
-
## v2.0.0-alpha.2
|
|
200
|
-
|
|
201
|
-
- __BREAKING__: Bump graphql peer dependency to `^15.7.0` [PR #1200](https://github.com/apollographql/federation/pull/1200)
|
|
202
|
-
|
|
203
|
-
## v2.0.0-alpha.1
|
|
204
|
-
|
|
205
|
-
- :tada: Initial alpha release of Federation 2.0. For more information, see our [documentation](https://www.apollographql.com/docs/federation/v2/). We look forward to your feedback!
|
package/jest.config.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const baseConfig = require('../jest.config.base');
|
|
2
|
-
|
|
3
|
-
/** @typedef {import('ts-jest/dist/types')} */
|
|
4
|
-
/** @type {import('@jest/types').Config.InitialOptions} */
|
|
5
|
-
module.exports = {
|
|
6
|
-
...baseConfig,
|
|
7
|
-
displayName: {
|
|
8
|
-
name: '@apollo/federation-internals',
|
|
9
|
-
color: 'magenta'
|
|
10
|
-
}
|
|
11
|
-
};
|