Skip to content

fix(dang): don't require id field for interface conformance - #77

Merged
vito merged 1 commit into
mainfrom
fix/interface-id-conformance
Jun 3, 2026
Merged

vito merged 1 commit into
mainfrom
fix/interface-id-conformance

Conversation

@vito

@vito vito commented Jun 3, 2026 •

Copy link
Copy Markdown
Owner

Problem

Dagger synthesizes an id: ID! field on every interface in a module's GraphQL schema, and supplies it for implementers automatically. When a Dang module imports an interface from a dependency schema, that synthesized id field is included in the interface's bindings. Dang's conformance checks then iterate every interface binding and demand the implementer provide each one — so a user type that says implements Foo fails with:

class Hi is missing `id(): ID!`, required by interface Dagger.DepGreeter

Locally-declared interfaces never carried the field (their bindings only contain the fields the user wrote), so this only surfaced across module boundaries — e.g. implementing an interface defined in a Dagger module dependency.

Fix

Skip the reserved id: ID! field in both conformance checks (validateInterfaceImplementations and validateInterfaceExtension) via a small isReservedInterfaceField helper. The guard is precise: it only exempts a field named id whose return type is the ID scalar, so a real id: String! field is still enforced. This matches Dagger's contract — id is reserved and runtime-synthesized for every implementer, so requiring the user to declare it is never correct.

Tests

  • tests/test_interface_id_not_required.dang — a type implementing an interface that declares id: ID! is allowed to omit id, while other interface fields (name) are still required. Verified to fail without the fix and pass with it.
  • tests/errors/interface_wrong_field_type.dang — this existing field-type-mismatch test happened to use id as its example field, so it now uses a non-reserved field (ref) to keep exercising the type-compatibility checker. Golden updated accordingly.

Full suite green: go test ./tests/ ./pkg/dang/.

Dagger synthesizes an `id: ID!` field on every interface in a module's
GraphQL schema and supplies it for implementers automatically. When an
interface is imported from a dependency schema, that synthesized field is
included in the interface's bindings, so conformance checks demanded that
user-defined types implement `id` themselves -- which they cannot and
should not. Locally declared interfaces never carried the field, so the
failure only surfaced across module boundaries.

Skip the reserved `id: ID!` field in both the object-implements-interface
and interface-extends-interface conformance checks. The existing
wrong-field-type error test happened to use `id` as its example field, so
it now uses a non-reserved field; a new test covers that `implements` no
longer requires `id` while still requiring the interface's other fields.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito merged commit e7156c3 into main Jun 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant