From c5722c7c356702bed154502cf92d6fffaeb5685d Mon Sep 17 00:00:00 2001 From: kleberbaum Date: Sat, 7 Feb 2026 11:26:11 +0100 Subject: [PATCH] fix: merge interface fields into derived types in SDL generation When a derived type declares `implements IFoo`, the SDL must include all interface fields in the derived type's field list. Without this, GraphQL schema validation fails at runtime: "Interface field IFoo.x expected but Bar does not provide it." The fix merges interface fields into derived type field lists during the `addInterfaceToDerived` pass, skipping fields already declared on the derived type. Fixes #110 --- .../pylon-dev/src/builder/schema/schema-parser.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/pylon-dev/src/builder/schema/schema-parser.ts b/packages/pylon-dev/src/builder/schema/schema-parser.ts index 34f1e85..6aa9ff5 100644 --- a/packages/pylon-dev/src/builder/schema/schema-parser.ts +++ b/packages/pylon-dev/src/builder/schema/schema-parser.ts @@ -317,6 +317,20 @@ export class SchemaParser { if (!derivedSchemaType.implements.includes(interfaceName)) { derivedSchemaType.implements.push(interfaceName) } + + // Ensure the derived type includes all interface fields. + // Without this, GraphQL schema validation fails: + // "Interface field IFoo.x expected but Bar does not provide it." + if (targetInterface) { + for (const ifaceField of targetInterface.fields) { + const alreadyHasField = derivedSchemaType.fields.some( + f => f.name === ifaceField.name + ) + if (!alreadyHasField) { + derivedSchemaType.fields.push({...ifaceField}) + } + } + } } // Check if this derived type is also a base type for other types