graphql-hive / graphql-hive/federation-composition
Referencing a root type `Query` in another type fails with an error about missing `@key`
- Dominant language
- TypeScript
- Stars
- 53
- Forks
- 8
- Avg merge
- 20h 50m
- Merged PRs (30d)
- 10
Description
When a root field `Query` is reference by anotoher type, for example, in case of a `viewer`-pattern implementation, it fails with an error like:
```
The following supergraph API query: mutation { doSomething { query { user(id: "") { ... } } } } cannot be satisfied by the subgraphs because: - from subgraph "two": - cannot find field "Query.user". - cannot move to subgraph "one", which has field "Query.user", because type "Query" has no @key defined in subgraph "one".
```
This seems to happen because the composition lib consider `Query` as a regular entity type that needs to be resolved, and not as a subgraph entrypoint.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the viewer-pattern case described in the issue, using the supergraph API query and the two subgraphs from the error. Trace composition and query planning where the root type Query is treated as an entity; done means the cross-subgraph query composes and plans without requiring a @key on Query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100