Skip to content

entgql: support GraphQL interfaces for nodes via the InterfaceField#638

Open
giautm wants to merge 4 commits into
masterfrom
g/entgql-interfaces
Open

entgql: support GraphQL interfaces for nodes via the InterfaceField#638
giautm wants to merge 4 commits into
masterfrom
g/entgql-interfaces

Conversation

@giautm

@giautm giautm commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

…nnotation

Add entgql.InterfaceField to expose edges from different node types under a shared GraphQL interface and generate polymorphic connections over it: edge-scoped connections (paginated in memory) and a global connection backed by a SQL view (DB-level pagination, orderBy and where), resolving each row to its concrete node so ... on Todo fragments work.

@giautm
giautm force-pushed the g/entgql-interfaces branch 3 times, most recently from c6f0d9e to e48c469 Compare July 18, 2026 10:18
@giautm
giautm requested a review from Copilot July 18, 2026 10:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@giautm
giautm force-pushed the g/entgql-interfaces branch 4 times, most recently from 056f53d to 9577833 Compare July 21, 2026 07:30
@giautm
giautm marked this pull request as ready for review July 21, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Comment thread entgql/schema.go
Comment thread entgql/template.go Outdated
Comment thread entgql/template/interface_view.tmpl
…ew template

When a node's GraphQL type name differs from the ent type name via
entgql.Type() (e.g. Workspace exposed as Organization), the discriminator
column in the view stores the GraphQL type name. Using $impl.Name (the
ent type name) for byKind lookups and nodes map keys would fail to match.

Add nodeGQLType template function and use it in place of $impl.Name for
both byKind lookups (line 422) and nodes map keys (line 457).
Remove the allEdgesUnique guard that was erroneously rejecting
multi-edge groups with non-unique (to-many) edges. schema.go already
handles both cases via its switch: all-unique groups produce a single
interface value, while non-unique groups produce an interface connection.
The old error made the default branch in schema.go unreachable.
@giautm
giautm requested review from a8m and masseelch July 21, 2026 14:20
@giautm giautm changed the title entgql: support GraphQL interfaces for nodes via the InterfaceField a… entgql: support GraphQL interfaces for nodes via the InterfaceField Jul 21, 2026
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.

3 participants