Skip to content

Commit 1257300

Browse files
committed
fix: implementation
1 parent d4d4f1d commit 1257300

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

__tests__/composition.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ testImplementations((api) => {
248248
`);
249249
});
250250

251-
test("@override(from:) no usedOverridden in case the overriden field is @external", () => {
251+
test("@override(from:) no usedOverridden in case the overriden field is @external but has matching interface fields", () => {
252252
const result = composeServices([
253253
{
254254
name: "a",

src/supergraph/composition/object-type.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { createObjectTypeNode, JoinFieldAST } from "./ast.js";
1818
import type { Key, MapByGraph, TypeBuilder } from "./common.js";
1919
import { convertToConst } from "./common.js";
2020
import { InterfaceTypeFieldState } from "./interface-type.js";
21+
import { isExternal } from "node:util/types";
2122

2223
export function isRealExtension(
2324
meta: ObjectTypeStateInGraph,
@@ -687,6 +688,16 @@ export function objectTypeBuilder(): TypeBuilder<ObjectType, ObjectTypeState> {
687688
);
688689
const isRequired = f.required === true;
689690

691+
const inGraphs =
692+
fieldNamesOfImplementedInterfaces[field.name];
693+
const hasMatchingInterfaceFieldInGraph: boolean =
694+
inGraphs && inGraphs.has(graphId);
695+
696+
// Apparently we need to keep it if it has a interface definition...
697+
if (hasMatchingInterfaceFieldInGraph) {
698+
return true;
699+
}
700+
690701
return (
691702
(isExternal && isRequired) ||
692703
needsToPrintOverrideLabel ||
@@ -1014,6 +1025,10 @@ function provideUsedOverriddenValue(
10141025
const isOverridden =
10151026
field.override && graphNameToId(field.override) === graphId;
10161027

1028+
if (isOverridden && fieldStateInGraph.external) {
1029+
return false;
1030+
}
1031+
10171032
if (
10181033
isOverridden &&
10191034
(isUsedAsNonExternalKey || hasMatchingInterfaceFieldInGraph)

0 commit comments

Comments
 (0)