Repository navigation
fix(dang): don't require id field for interface conformance - #77
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 synthesizedidfield 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 saysimplements Foofails with: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 (validateInterfaceImplementationsandvalidateInterfaceExtension) via a smallisReservedInterfaceFieldhelper. The guard is precise: it only exempts a field namedidwhose return type is theIDscalar, so a realid: String!field is still enforced. This matches Dagger's contract —idis 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 declaresid: ID!is allowed to omitid, 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 useidas 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/.