apollographql / apollographql/federation
Unexpected query planner error with union, fragments and @include
- Dominant language
- TypeScript
- Stars
- 727
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
### Issue Description
We use the [router](https://github.com/apollographql/router) v1.33.0 and got this query planner error in production
### Link to Reproduction
Reproduction steps below
### Reproduction Steps
Minimal supergraph to reproduce
```
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
{
query: Query
}
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA
type A
@join__type(graph: SUBGRAPH1)
{
foo: Int!
}
type B
@join__type(graph: SUBGRAPH1, key: "bar")
@join__type(graph: SUBGRAPH2, key: "bar")
{
bar: Int!
}
scalar join__FieldSet
enum join__Graph {
SUBGRAPH1 @join__graph(name: "subgraph1", url: "http://localhost:3000")
SUBGRAPH2 @join__graph(name: "subgraph2", url: "http://localhost:5000")
}
scalar link__Import
enum link__Purpose {
"""
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY
"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
EXECUTION
}
type Query
@join__type(graph: SUBGRAPH1)
@join__type(graph: SUBGRAPH2)
{
b: B! @join__field(graph: SUBGRAPH1)
}
union U
@join__type(graph: SUBGRAPH1)
@join__unionMember(graph: SUBGRAPH1, member: "A")
@join__unionMember(graph: SUBGRAPH1, member: "B")
= A | B
```
Query to reproduce
```
{
b {
... on U @include(if: true) {
... on B {
bar
}
}
}
}
```
The query results in this error:
[
{
"message": "value retrieval failed: router bridge error: the deno runtime raised an error: `request: couldn't receive response couldn't deserialize payload `10667488625103102209`: `deno: couldn't deserialize response : `Error(\"invalid neither null nor empty object: found Object {\\\"code\\\": String(\\\"QUERY_PLANNING_FAILED\\\"), \\\"exception\\\": Object {\\\"stacktrace\\\": Array [String(\\\"Cannot add selection of field \\\\\\\"B.bar\\\\\\\" to selection set of parent type \\\\\\\"U\\\\\\\"\\\")]}}\", line: 0, column: 0)``.`",
"extensions": {
"code": "INTERNAL_SERVER_ERROR"
}
}
]
Contributor guide
Research direction
Start by running the minimal supergraph and query from the issue against router v1.33.0, focusing on the union, nested fragments, and @include directive. The work is done when this reproduction no longer raises QUERY_PLANNING_FAILED or the reported “Cannot add selection” error during query planning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100