@apollo/composition
Advanced tools
Comparing version 2.9.0-connectors.7 to 2.9.0-connectors.8
@@ -7,2 +7,3 @@ "use strict"; | ||
const reporter_1 = require("./merging/reporter"); | ||
const merging_1 = require("./merging"); | ||
const directiveHasDifferentNameInSubgraph = ({ subgraph, origName, expectedName, identity, }) => { | ||
@@ -234,3 +235,3 @@ var _a, _b, _c, _d; | ||
} | ||
this.mismatchReporter.reportMismatchErrorWithoutSupergraph(federation_internals_1.ERRORS.DIRECTIVE_COMPOSITION_ERROR, 'Composed directive is not named consistently in all subgraphs', this.subgraphs.values() | ||
this.mismatchReporter.reportMismatchErrorWithoutSupergraph(federation_internals_1.ERRORS.DIRECTIVE_COMPOSITION_ERROR, 'Composed directive is not named consistently in all subgraphs', (0, merging_1.sourcesFromArray)(this.subgraphs.values() | ||
.map(sg => { | ||
@@ -253,3 +254,3 @@ const item = items.find(item => sg.name === item.sgName); | ||
} : undefined; | ||
}), (elt) => elt ? `"@${elt.item.directiveNameAs}"` : undefined); | ||
})), (elt) => elt ? `"@${elt.item.directiveNameAs}"` : undefined); | ||
} | ||
@@ -256,0 +257,0 @@ const nonExportedSubgraphs = this.subgraphs.values() |
@@ -12,3 +12,3 @@ "use strict"; | ||
const source = features.sourceFeature(directive); | ||
if (!source || directive.applications().length === 0) { | ||
if (!source || directive.applications().size === 0) { | ||
continue; | ||
@@ -15,0 +15,0 @@ } |
@@ -5,2 +5,4 @@ import { Schema, Subgraphs } from "@apollo/federation-internals"; | ||
import { CompositionOptions } from "../compose"; | ||
export type Sources<T> = Map<number, T | undefined>; | ||
export declare function sourcesFromArray<T>(array: (T | undefined)[]): Sources<T>; | ||
export type MergeResult = MergeSuccess | MergeFailure; | ||
@@ -7,0 +9,0 @@ export interface MergeSuccess { |
import { ErrorCodeDefinition, NamedSchemaElement, SubgraphASTNode } from '@apollo/federation-internals'; | ||
import { ASTNode, GraphQLError } from 'graphql'; | ||
import { CompositionHint, HintCodeDefinition } from '../hints'; | ||
import { Sources } from './merge'; | ||
export declare class MismatchReporter { | ||
@@ -11,6 +12,6 @@ readonly names: readonly string[]; | ||
sourceAST?: ASTNode; | ||
}>(code: ErrorCodeDefinition, message: string, mismatchedElement: TMismatched, subgraphElements: (TMismatched | undefined)[], mismatchAccessor: (elt: TMismatched, isSupergraph: boolean) => string | undefined): void; | ||
}>(code: ErrorCodeDefinition, message: string, mismatchedElement: TMismatched, subgraphElements: Sources<TMismatched>, mismatchAccessor: (elt: TMismatched, isSupergraph: boolean) => string | undefined): void; | ||
reportMismatchErrorWithoutSupergraph<TMismatched extends { | ||
sourceAST?: ASTNode; | ||
}>(code: ErrorCodeDefinition, message: string, subgraphElements: (TMismatched | undefined)[], mismatchAccessor: (elt: TMismatched, isSupergraph: boolean) => string | undefined): void; | ||
}>(code: ErrorCodeDefinition, message: string, subgraphElements: Sources<TMismatched>, mismatchAccessor: (elt: TMismatched, isSupergraph: boolean) => string | undefined): void; | ||
reportMismatchErrorWithSpecifics<TMismatched extends { | ||
@@ -22,3 +23,3 @@ sourceAST?: ASTNode; | ||
mismatchedElement: TMismatched; | ||
subgraphElements: (TMismatched | undefined)[]; | ||
subgraphElements: Sources<TMismatched>; | ||
mismatchAccessor: (elt: TMismatched | undefined, isSupergraph: boolean) => string | undefined; | ||
@@ -37,3 +38,3 @@ supergraphElementPrinter: (elt: string, subgraphs: string | undefined) => string; | ||
supergraphElement: TMismatched; | ||
subgraphElements: (TMismatched | undefined)[]; | ||
subgraphElements: Sources<TMismatched>; | ||
targetedElement?: NamedSchemaElement<any, any, any>; | ||
@@ -40,0 +41,0 @@ elementToString: (elt: TMismatched, isSupergraph: boolean) => string | undefined; |
@@ -36,18 +36,30 @@ "use strict"; | ||
const astNodes = []; | ||
for (const [i, subgraphElt] of subgraphElements.entries()) { | ||
if (!subgraphElt) { | ||
if (includeMissingSources) { | ||
distributionMap.add('', this.names[i]); | ||
} | ||
continue; | ||
} | ||
const processSubgraphElt = (name, subgraphElt) => { | ||
if (ignorePredicate && ignorePredicate(subgraphElt)) { | ||
continue; | ||
return; | ||
} | ||
const elt = mismatchAccessor(subgraphElt, false); | ||
distributionMap.add(elt !== null && elt !== void 0 ? elt : '', this.names[i]); | ||
distributionMap.add(elt !== null && elt !== void 0 ? elt : '', name); | ||
if (subgraphElt.sourceAST) { | ||
astNodes.push((0, federation_internals_1.addSubgraphToASTNode)(subgraphElt.sourceAST, this.names[i])); | ||
astNodes.push((0, federation_internals_1.addSubgraphToASTNode)(subgraphElt.sourceAST, name)); | ||
} | ||
}; | ||
if (includeMissingSources) { | ||
for (const [i, name] of this.names.entries()) { | ||
const subgraphElt = subgraphElements.get(i); | ||
if (!subgraphElt) { | ||
distributionMap.add('', name); | ||
continue; | ||
} | ||
processSubgraphElt(name, subgraphElt); | ||
} | ||
} | ||
else { | ||
for (const [i, subgraphElt] of subgraphElements.entries()) { | ||
if (!subgraphElt) { | ||
continue; | ||
} | ||
processSubgraphElt(this.names[i], subgraphElt); | ||
} | ||
} | ||
const supergraphMismatch = (_a = (supergraphElement && mismatchAccessor(supergraphElement, true))) !== null && _a !== void 0 ? _a : ''; | ||
@@ -54,0 +66,0 @@ (0, federation_internals_1.assert)(distributionMap.size > 1, () => `Should not have been called for ${supergraphElement}`); |
@@ -278,3 +278,3 @@ "use strict"; | ||
const options = (0, query_graphs_1.advancePathWithTransition)(path, transition, targetType, newOverrideConditions); | ||
if ((0, query_graphs_1.isUnadvanceable)(options)) { | ||
if ((0, query_graphs_1.isUnadvanceableClosures)(options)) { | ||
deadEnds.push(options); | ||
@@ -302,3 +302,3 @@ continue; | ||
if (newSubgraphPathInfos.length === 0) { | ||
return { error: satisfiabilityError(newPath, this.subgraphPathInfos.map((p) => p.path.path), deadEnds) }; | ||
return { error: satisfiabilityError(newPath, this.subgraphPathInfos.map((p) => p.path.path), deadEnds.map((d) => d.toUnadvanceables())) }; | ||
} | ||
@@ -403,3 +403,3 @@ const updatedState = new ValidationState(newPath, newSubgraphPathInfos, newOverrideConditions); | ||
}))); | ||
this.previousVisits = new query_graphs_1.QueryGraphState(supergraphAPI); | ||
this.previousVisits = new query_graphs_1.QueryGraphState(); | ||
this.context = new ValidationContext(supergraphSchema, subgraphNameToGraphEnumValue); | ||
@@ -406,0 +406,0 @@ } |
{ | ||
"name": "@apollo/composition", | ||
"version": "2.9.0-connectors.7", | ||
"version": "2.9.0-connectors.8", | ||
"description": "Apollo Federation composition utilities", | ||
@@ -30,4 +30,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@apollo/federation-internals": "2.9.0-connectors.7", | ||
"@apollo/query-graphs": "2.9.0-connectors.7" | ||
"@apollo/federation-internals": "2.9.0-connectors.8", | ||
"@apollo/query-graphs": "2.9.0-connectors.8" | ||
}, | ||
@@ -34,0 +34,0 @@ "peerDependencies": { |
@@ -18,2 +18,3 @@ import { | ||
import { MismatchReporter } from './merging/reporter'; | ||
import { sourcesFromArray } from './merging'; | ||
@@ -371,3 +372,3 @@ /** | ||
'Composed directive is not named consistently in all subgraphs', | ||
this.subgraphs.values() | ||
sourcesFromArray(this.subgraphs.values() | ||
.map(sg => { | ||
@@ -389,3 +390,3 @@ const item = items.find(item => sg.name === item.sgName); | ||
} : undefined; | ||
}), | ||
})), | ||
(elt) => elt ? `"@${elt.item.directiveNameAs}"` : undefined | ||
@@ -392,0 +393,0 @@ ); |
@@ -24,3 +24,3 @@ import { assert, coreFeatureDefinitionIfKnown, DirectiveCompositionSpecification, DirectiveDefinition, FeatureUrl, isDefined, mapValues, Subgraphs } from "@apollo/federation-internals"; | ||
// happen to ignore execution directives as a by-product) | ||
if (!source || directive.applications().length === 0) { | ||
if (!source || directive.applications().size === 0) { | ||
continue; | ||
@@ -27,0 +27,0 @@ } |
import { addSubgraphToASTNode, assert, ErrorCodeDefinition, joinStrings, MultiMap, NamedSchemaElement, printSubgraphNames, SubgraphASTNode } from '@apollo/federation-internals'; | ||
import { ASTNode, GraphQLError } from 'graphql'; | ||
import { CompositionHint, HintCodeDefinition } from '../hints'; | ||
import { Sources } from './merge'; | ||
@@ -18,3 +19,3 @@ export class MismatchReporter { | ||
mismatchedElement:TMismatched, | ||
subgraphElements: (TMismatched | undefined)[], | ||
subgraphElements: Sources<TMismatched>, | ||
mismatchAccessor: (elt: TMismatched, isSupergraph: boolean) => string | undefined | ||
@@ -41,3 +42,3 @@ ) { | ||
message: string, | ||
subgraphElements: (TMismatched | undefined)[], | ||
subgraphElements: Sources<TMismatched>, | ||
mismatchAccessor: (elt: TMismatched, isSupergraph: boolean) => string | undefined | ||
@@ -76,3 +77,3 @@ ) { | ||
mismatchedElement: TMismatched, | ||
subgraphElements: (TMismatched | undefined)[], | ||
subgraphElements: Sources<TMismatched>, | ||
mismatchAccessor: (elt: TMismatched | undefined, isSupergraph: boolean) => string | undefined, | ||
@@ -118,3 +119,3 @@ supergraphElementPrinter: (elt: string, subgraphs: string | undefined) => string, | ||
supergraphElement: TMismatched, | ||
subgraphElements: (TMismatched | undefined)[], | ||
subgraphElements: Sources<TMismatched>, | ||
targetedElement?: NamedSchemaElement<any, any, any> | ||
@@ -150,3 +151,3 @@ elementToString: (elt: TMismatched, isSupergraph: boolean) => string | undefined, | ||
supergraphElement:TMismatched | undefined, | ||
subgraphElements: (TMismatched | undefined)[], | ||
subgraphElements: Sources<TMismatched>, | ||
mismatchAccessor: (element: TMismatched, isSupergraph: boolean) => string | undefined, | ||
@@ -161,18 +162,29 @@ supergraphElementPrinter: (elt: string, subgraphs: string | undefined) => string, | ||
const astNodes: SubgraphASTNode[] = []; | ||
for (const [i, subgraphElt] of subgraphElements.entries()) { | ||
if (!subgraphElt) { | ||
if (includeMissingSources) { | ||
distributionMap.add('', this.names[i]); | ||
} | ||
continue; | ||
} | ||
const processSubgraphElt = (name: string, subgraphElt: TMismatched) => { | ||
if (ignorePredicate && ignorePredicate(subgraphElt)) { | ||
continue; | ||
return; | ||
} | ||
const elt = mismatchAccessor(subgraphElt, false); | ||
distributionMap.add(elt ?? '', this.names[i]); | ||
distributionMap.add(elt ?? '', name); | ||
if (subgraphElt.sourceAST) { | ||
astNodes.push(addSubgraphToASTNode(subgraphElt.sourceAST, this.names[i])); | ||
astNodes.push(addSubgraphToASTNode(subgraphElt.sourceAST, name)); | ||
} | ||
} | ||
if (includeMissingSources) { | ||
for (const [i, name] of this.names.entries()) { | ||
const subgraphElt = subgraphElements.get(i); | ||
if (!subgraphElt) { | ||
distributionMap.add('', name); | ||
continue; | ||
} | ||
processSubgraphElt(name, subgraphElt); | ||
} | ||
} else { | ||
for (const [i, subgraphElt] of subgraphElements.entries()) { | ||
if (!subgraphElt) { | ||
continue; | ||
} | ||
processSubgraphElt(this.names[i], subgraphElt); | ||
} | ||
} | ||
const supergraphMismatch = (supergraphElement && mismatchAccessor(supergraphElement, true)) ?? ''; | ||
@@ -179,0 +191,0 @@ assert(distributionMap.size > 1, () => `Should not have been called for ${supergraphElement}`); |
@@ -54,3 +54,2 @@ import { | ||
Unadvanceables, | ||
isUnadvanceable, | ||
Unadvanceable, | ||
@@ -62,2 +61,4 @@ noConditionsResolution, | ||
ConditionResolver, | ||
UnadvanceableClosures, | ||
isUnadvanceableClosures, | ||
} from "@apollo/query-graphs"; | ||
@@ -491,3 +492,3 @@ import { CompositionHint, HINTS } from "./hints"; | ||
const newSubgraphPathInfos: SubgraphPathInfo[] = []; | ||
const deadEnds: Unadvanceables[] = []; | ||
const deadEnds: UnadvanceableClosures[] = []; | ||
// If the edge has an override condition, we should capture it in the state so | ||
@@ -510,3 +511,3 @@ // that we can ignore later edges that don't satisfy the condition. | ||
); | ||
if (isUnadvanceable(options)) { | ||
if (isUnadvanceableClosures(options)) { | ||
deadEnds.push(options); | ||
@@ -540,3 +541,3 @@ continue; | ||
if (newSubgraphPathInfos.length === 0) { | ||
return { error: satisfiabilityError(newPath, this.subgraphPathInfos.map((p) => p.path.path), deadEnds) }; | ||
return { error: satisfiabilityError(newPath, this.subgraphPathInfos.map((p) => p.path.path), deadEnds.map((d) => d.toUnadvanceables())) }; | ||
} | ||
@@ -713,3 +714,3 @@ | ||
}))); | ||
this.previousVisits = new QueryGraphState(supergraphAPI); | ||
this.previousVisits = new QueryGraphState(); | ||
this.context = new ValidationContext( | ||
@@ -716,0 +717,0 @@ supergraphSchema, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
625602
9048
+ Added@apollo/federation-internals@2.9.0-connectors.8(transitive)
+ Added@apollo/query-graphs@2.9.0-connectors.8(transitive)
- Removed@apollo/federation-internals@2.9.0-connectors.7(transitive)
- Removed@apollo/query-graphs@2.9.0-connectors.7(transitive)