Hello, I think we just hit an edge case where the query planner fails to create a plan for a query that uses @skip or @include directives for a field that has @requires and also accepts inputs.
To Reproduce
Steps to reproduce the behavior:
We will need 2 subgraphs, in this example, product and shipping.
Product Schema:
@link(
url: "https://specs.apollo.dev/federation/v2.3"
import: ["@key"]
)
type Query {
allProducts: [Product!]
}
type Product @key(fields: "id") {
id: ID!
dimensions(unitType: UnitType): ProductDimensions
}
type ProductDimensions {
size: Int
weight: Int
}
enum UnitType {
METRIC
IMPERIAL
}
Shipping Schema:
@link(
url: "https://specs.apollo.dev/federation/v2.3"
import: ["@key", "@external", "@requires"]
)
extend type Product @key(fields: "id") {
id: ID!
dimensions(unitType: UnitType): ProductDimensions @external
shippingEstimate: Int @requires(fields: "dimensions { size weight }")
}
extend type ProductDimensions {
size: Int @external
weight: Int @external
}
enum UnitType {
METRIC
IMPERIAL
}
3. You will get the following error:
- When using the JS query planner:
"Fields \"dimensions\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional."
- When using the Rust query planner:
"value retrieval failed: Federation error: An internal error has occurred, please report this bug to Apollo.\n\nDetails: Query planning produced an invalid subgraph operation.\nError: operation must not provide conflicting field arguments for the same name dimensions\n"
## Expected behavior
Ideally this should not fail. Also, when removing either the `unitType` input or the `@include` directive from the query it works just fine.
## Desktop (please complete the following information):
- OS: macOS Sonoma 14.6.1
- Router Version: v1.57.0
## Off-topic but also related (Maybe this deserves another dedicated issue)
We would love to be able to tell router to use the `unitType` input (when available in the query) when fetching the field to fulfill the the `@requires` directive, example:
```graphql
extend type Product @key(fields: "id") {
id: ID!
dimensions(unitType: UnitType): ProductDimensions @external
shippingEstimate: Int @requires(fields: "dimensions(unitType: $unitType) { size weight }")
Inject it here ---------------------------------------------------^
}
So both requested dimensions field and the shippingEstimate would use the same input defined by the client. Currently we can't guarantee that the dimensions used to calculate the shippingEstimate will use the correct unitType.
Describe the bug
Hello, I think we just hit an edge case where the query planner fails to create a plan for a query that uses
@skip
or@include
directives for a field that has@requires
and also accepts inputs.To Reproduce
Steps to reproduce the behavior:
product
andshipping
.Product Schema:
Shipping Schema:
The supergraph:
"Fields \"dimensions\" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional."
"value retrieval failed: Federation error: An internal error has occurred, please report this bug to Apollo.\n\nDetails: Query planning produced an invalid subgraph operation.\nError: operation must not provide conflicting field arguments for the same name
dimensions
\n"So both requested
dimensions
field and theshippingEstimate
would use the same input defined by the client. Currently we can't guarantee that thedimensions
used to calculate theshippingEstimate
will use the correctunitType
.