Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions composition-go/index.global.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions composition/src/schema-building/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export type FieldData = {
directivesByDirectiveName: Map<string, Array<ConstDirectiveNode>>;
externalFieldDataBySubgraphName: Map<string, ExternalFieldData>;
federatedCoords: string;
inheritedDirectiveNames: Set<string>;
isInaccessible: boolean;
isShareableBySubgraphName: Map<string, boolean>;
kind: Kind.FIELD_DEFINITION;
Expand Down
2 changes: 2 additions & 0 deletions composition/src/v1/federation/federation-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,8 @@ export class FederationFactory {
directivesByDirectiveName: copyArrayValueMap(sourceData.directivesByDirectiveName),
externalFieldDataBySubgraphName: copyObjectValueMap(sourceData.externalFieldDataBySubgraphName),
federatedCoords: sourceData.federatedCoords,
// Intentionally reset; only the subgraph fields involve directive inheritance
inheritedDirectiveNames: new Set<string>(),
Comment thread
Aenimus marked this conversation as resolved.
isInaccessible: sourceData.isInaccessible,
isShareableBySubgraphName: new Map(sourceData.isShareableBySubgraphName),
kind: sourceData.kind,
Expand Down
17 changes: 12 additions & 5 deletions composition/src/v1/normalization/normalization-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,12 +550,17 @@ export class NormalizationFactory {
}
}

addInheritedDirectivesToFieldData(fieldDirectivesByDirectiveName: Map<string, Array<ConstDirectiveNode>>) {
if (this.isParentObjectShareable) {
getValueOrDefault(fieldDirectivesByDirectiveName, SHAREABLE, () => [generateSimpleDirective(SHAREABLE)]);
addInheritedDirectivesToFieldData(
fieldDirectivesByDirectiveName: Map<string, Array<ConstDirectiveNode>>,
inheritedDirectiveNames: Set<string>,
) {
if (this.isParentObjectShareable && !fieldDirectivesByDirectiveName.has(SHAREABLE)) {
fieldDirectivesByDirectiveName.set(SHAREABLE, [generateSimpleDirective(SHAREABLE)]);
inheritedDirectiveNames.add(SHAREABLE);
}
if (this.isParentObjectExternal) {
getValueOrDefault(fieldDirectivesByDirectiveName, EXTERNAL, () => [generateSimpleDirective(EXTERNAL)]);
if (this.isParentObjectExternal && !fieldDirectivesByDirectiveName.has(EXTERNAL)) {
fieldDirectivesByDirectiveName.set(EXTERNAL, [generateSimpleDirective(EXTERNAL)]);
inheritedDirectiveNames.add(EXTERNAL);
}
return fieldDirectivesByDirectiveName;
}
Expand Down Expand Up @@ -1071,6 +1076,7 @@ export class NormalizationFactory {
node: FieldDefinitionNode,
argumentDataByArgumentName: Map<string, InputValueData>,
directivesByDirectiveName: Map<string, ConstDirectiveNode[]>,
inheritedDirectiveNames: Set<string> = new Set<string>(),
): FieldData {
const name = node.name.value;
const parentTypeName = this.renamedParentTypeName || this.originalParentTypeName;
Expand All @@ -1088,6 +1094,7 @@ export class NormalizationFactory {
[this.subgraphName, newExternalFieldData(isExternal)],
]),
federatedCoords: `${parentTypeName}.${name}`,
inheritedDirectiveNames,
isInaccessible: directivesByDirectiveName.has(INACCESSIBLE),
isShareableBySubgraphName: new Map<string, boolean>([[this.subgraphName, isShareable]]),
kind: Kind.FIELD_DEFINITION,
Expand Down
4 changes: 3 additions & 1 deletion composition/src/v1/normalization/walkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,10 @@ export function upsertParentsAndChildren(nf: NormalizationFactory, document: Doc
}
const argumentDataByArgumentName = nf.extractArguments(new Map<string, InputValueData>(), node);
const directivesByDirectiveName = nf.extractDirectives(node, new Map<string, ConstDirectiveNode[]>());
const inheritedDirectiveNames = new Set<string>();
// Add parent-level shareable and external to the field extraction and repeatable validation
if (!isParentDataInterfaceType(parentData)) {
nf.addInheritedDirectivesToFieldData(directivesByDirectiveName);
nf.addInheritedDirectivesToFieldData(directivesByDirectiveName, inheritedDirectiveNames);
if (directivesByDirectiveName.has(EXTERNAL)) {
nf.unvalidatedExternalFieldCoords.add(`${nf.originalParentTypeName}.${fieldName}`);
}
Expand All @@ -372,6 +373,7 @@ export function upsertParentsAndChildren(nf: NormalizationFactory, document: Doc
node,
argumentDataByArgumentName,
directivesByDirectiveName,
inheritedDirectiveNames,
);
if (isParentRootType) {
nf.extractEventDirectivesToConfiguration(node, argumentDataByArgumentName);
Expand Down
Loading