Fusion executor issues with renamed arguments and types
Product
Hot Chocolate
Version
14.0.0-rc.0
Link to minimal reproduction
Steps to reproduce
The Accounts subgraph schema fragment
type Query {
tryRenameArgument(name: String!): String @cost(weight: "10")
tryRenameInput(input: NameInput!): String @cost(weight: "10")
}
input NameInput {
name: String!
}
Renaming directives in Accounts/schema.extensions.graphql
The argument name is renamed to name2 and the type NameInput is renamed to NameInput2.
extend schema
@rename(coordinate: "NameInput", newName: "NameInput2")
@rename(coordinate: "Query.tryRenameArgument(name:)", newName: "name2")
{
}
The result Gateway schema fragment with expected renaming
type Query {
tryRenameArgument(name2: String!): String
tryRenameInput(input: NameInput2!): String
}
input NameInput2 {
name: String!
}
Problem with renamed argument
Query
query TryRenameArgument {
tryRenameArgument(name2: "May")
}
Expected result
The string "try May" is returned.
Actual response
{
"errors": [
{
"message": "The argument `name` is required.",
"extensions": {
"type": "Query",
"field": "tryRenameArgument",
"argument": "name",
"specifiedBy": "https://spec.graphql.org/October2021/#sec-Required-Arguments"
}
},
{
"message": "The argument `name2` does not exist.",
"extensions": {
"type": "Query",
"field": "tryRenameArgument",
"argument": "name2",
"specifiedBy": "https://spec.graphql.org/October2021/#sec-Required-Arguments"
}
}
],
"data": {
"tryRenameArgument": null
}
}
Problem with renamed type variable
Query
query TryRenameInput($input: NameInput2!) {
tryRenameInput(input: $input)
}
{
"input": {"name": "Joe"}
}
Expected result
The string "try Joe" is returned.
Actual response
{
"errors": [
{
"message": "The variable `input` is not compatible with the type of the current location.",
"path": [
"tryRenameInput"
],
"extensions": {
"variable": "input",
"variableType": "NameInput2!",
"locationType": "NameInput!",
"specifiedBy": "https://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed"
}
}
],
"data": {
"tryRenameInput": null
}
}
What is expected?
see above
What is actually happening?
see above
Relevant log output
No response
Additional context
No response
@michaelstaib - any news on when renaming might be supported in HC Fusion?
(For context, we are looking at deciding very soon between sticking with the Fusion and Nitro/Hive, versus the Apollo Router/GraphOS stack.)
Apollo, The Guild, and ChilliCream are collaborating on the Composite Schema Specification, a unified specification for federated GraphQL. Neither the Composite Schema Specification nor the proprietary Apollo Federation supports renaming arguments or renaming any other type system member.
Here are the specifications for reference:
- Composite Schema Specification: https://graphql.github.io/composite-schemas-spec/
- Apollo Federation Subgraph Specification: https://www.apollographql.com/docs/graphos/reference/federation/subgraph-spec
Fusion, in versions 13, 14, and 15, is still based on our initial work on the Composite Schema Specification. We are currently implementing the latest draft of the specification and expect to release preview versions in the next two months. You can follow the work here: https://github.com/ChilliCream/graphql-platform/tree/main/src/HotChocolate/Fusion-vnext
Regarding renaming, federated GraphQL does not support renaming at all. The necessary adjustments for Fusion or Apollo Federation are the same - you will need to modify how you design your subgraphs. If you choose Apollo, we provide an integration for Apollo with the HotChocolate.ApolloFederation package.
If you are looking for a schema stitching approach (like we did with HotChocolate.Stitching), The Guild still provides its Hive Gateway, which is based on schema stitching. However, The Guild is also moving away from this approach.
If you need conceptual guidance on transitioning from a schema stitching approach to federated GraphQL, let us know, and we will be happy to hop on a call with you - [email protected].