entgql: decouple Relay global node lookup from pagination (WithRelaySpec bundles Node + Cursor/PageInfo)
Problem
entgql.WithRelaySpec(true) bundles three independent Relay features into one switch:
- Pagination types:
Cursorscalar andPageInfo(relay.dev Cursor Connections spec) - The
Nodeinterface plusimplements Nodeon every entity (Global Object Identification spec) - The
node(id:)/nodes(ids:)root queries
Meanwhile entgql.RelayConnection() hard-requires WithRelaySpec (ErrRelaySpecDisabled), even though a connection field only actually needs Cursor + PageInfo. The two Relay specs are independent: connections do not require global object identification.
Concrete pain: Apollo Federation
In a federated setup where one subgraph owns Query.node, every other subgraph that wants cursor pagination is forced to also expose a global node/nodes lookup. If the subgraphs' Node runtime types are disjoint, the supergraph fails composition with SHAREABLE_HAS_MISMATCHED_RUNTIME_TYPES — the schemas are uncomposable unless the node lookup is stripped from the published subgraph SDL, which breaks rover supergraph compose against schema.subgraph_url (introspection): the runtime schema simply isn't composable.
So today teams must choose: no Relay pagination, or post-process the generated schema to remove node/nodes.
Proposal
Add a fine-grained option, e.g. entgql.WithRelayNode(false), that keeps pagination (Cursor/PageInfo/RelayConnection) intact while omitting the Node interface, the node/nodes root queries, and the implements Node declarations. Default true for backward compatibility; effective only when the relay spec is enabled.
Reference implementation
I have a working implementation with tests on a fork branch (based on 9ac472ad):
- Branch:
relay-node-toggle— https://github.com/stark-sim/contrib/tree/relay-node-toggle - Splits
relayBuiltinTypes()into pagination types +relayNodeType(pkg) - Gates
relayBuiltinQueryFields()and theimplements Nodeappend on the new flag - Adds golden test
TestEntGQL_buildTypes_todoplugin_relay_nonode
Happy to open a PR referencing this issue if the approach sounds reasonable.
Source: ent/ent