Skip to content

[Fusion] Fixed issue causing duplicated forwarded variables #8311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -608,16 +608,11 @@ protected void TryForwardVariable(
var originalVarDef = context.Operation.Definition.VariableDefinitions
.First(t => t.Variable.Equals(variableValue, SyntaxComparison.Syntax));

if (resolver is null || !resolver.ArgumentTypes.TryGetValue(argumentName, out var type))
{
type = originalVarDef.Type;
}

context.ForwardedVariables.Add(
new VariableDefinitionNode(
null,
variableValue,
type,
originalVarDef.Type,
originalVarDef.DefaultValue,
Array.Empty<DirectiveNode>()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ schema {

type Query {
errorField: String
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
userById(id: ID!): User
users: [User!]!
usersById(ids: [ID!]!): [User!]!
Expand Down Expand Up @@ -66,6 +67,7 @@ schema @fusion(version: 1) @transport(subgraph: "Accounts", group: "Fusion", loc

type Query {
errorField: String @resolver(subgraph: "Accounts", select: "{ errorField }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int @variable(subgraph: "Accounts", name: "first", argument: "first") @variable(subgraph: "Accounts", name: "second", argument: "second") @resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
userById(id: ID!): User @variable(subgraph: "Accounts", name: "id", argument: "id") @resolver(subgraph: "Accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
users: [User!]! @resolver(subgraph: "Accounts", select: "{ users }")
usersById(ids: [ID!]!): [User!]! @variable(subgraph: "Accounts", name: "ids", argument: "ids") @resolver(subgraph: "Accounts", select: "{ usersById(ids: $ids) }", arguments: [ { name: "ids", type: "[ID!]!" } ])
Expand Down Expand Up @@ -117,7 +119,7 @@ scalar Date
```json
{
"Name": "Accounts",
"Schema": "schema {\n query: Query\n mutation: Mutation\n}\n\n\"The node interface is implemented by entities that have a global unique identifier.\"\ninterface Node {\n id: ID!\n}\n\ntype Query {\n \"Fetches an object given its ID.\"\n node(\"ID of the object.\" id: ID!): Node\n \"Lookup nodes by a list of IDs.\"\n nodes(\"The list of node IDs.\" ids: [ID!]!): [Node]!\n users: [User!]!\n userById(id: ID!): User\n usersById(ids: [ID!]!): [User!]!\n errorField: String\n viewer: Viewer!\n}\n\ntype Mutation {\n addUser(input: AddUserInput!): AddUserPayload!\n}\n\n\"The `Date` scalar represents an ISO-8601 compliant date type.\"\nscalar Date\n\ntype Viewer {\n user: User\n data: SomeData!\n}\n\ntype User implements Node {\n errorField: String\n id: ID!\n name: String!\n birthdate: Date!\n username: String!\n}\n\ntype SomeData {\n accountValue: String!\n}\n\ninput AddUserInput {\n name: String!\n username: String!\n birthdate: Date!\n}\n\ntype AddUserPayload {\n user: User\n}",
"Schema": "schema {\n query: Query\n mutation: Mutation\n}\n\n\"The node interface is implemented by entities that have a global unique identifier.\"\ninterface Node {\n id: ID!\n}\n\ntype Query {\n \"Fetches an object given its ID.\"\n node(\"ID of the object.\" id: ID!): Node\n \"Lookup nodes by a list of IDs.\"\n nodes(\"The list of node IDs.\" ids: [ID!]!): [Node]!\n users: [User!]!\n userById(id: ID!): User\n usersById(ids: [ID!]!): [User!]!\n errorField: String\n testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int\n viewer: Viewer!\n}\n\ntype Mutation {\n addUser(input: AddUserInput!): AddUserPayload!\n}\n\n\"The `Date` scalar represents an ISO-8601 compliant date type.\"\nscalar Date\n\ntype User implements Node {\n errorField: String\n id: ID!\n name: String!\n birthdate: Date!\n username: String!\n}\n\ntype Viewer {\n user: User\n data: SomeData!\n}\n\ntype SomeData {\n accountValue: String!\n}\n\ninput AddUserInput {\n name: String!\n username: String!\n birthdate: Date!\n}\n\ntype AddUserPayload {\n user: User\n}",
"Extensions": [
"extend type Query {\n userById(id: ID!\n @is(field: \"id\")): User!\n usersById(ids: [ID!]!\n @is(field: \"id\")): [User!]!\n}"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Query {
reviewById(id: ID!): Review
reviewOrAuthor: ReviewOrAuthor!
reviews: [Review!]!
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
userById(id: ID!): User
users: [User!]!
usersById(ids: [ID!]!): [User!]!
Expand Down Expand Up @@ -111,6 +112,7 @@ type Query {
reviewById(id: ID!): Review @variable(subgraph: "Reviews2", name: "id", argument: "id") @resolver(subgraph: "Reviews2", select: "{ reviewById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
reviewOrAuthor: ReviewOrAuthor! @resolver(subgraph: "Reviews2", select: "{ reviewOrAuthor }")
reviews: [Review!]! @resolver(subgraph: "Reviews2", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int @variable(subgraph: "Accounts", name: "first", argument: "first") @variable(subgraph: "Accounts", name: "second", argument: "second") @resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
userById(id: ID!): User @variable(subgraph: "Accounts", name: "id", argument: "id") @resolver(subgraph: "Accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ]) @variable(subgraph: "Reviews2", name: "id", argument: "id") @resolver(subgraph: "Reviews2", select: "{ authorById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
users: [User!]! @resolver(subgraph: "Accounts", select: "{ users }")
usersById(ids: [ID!]!): [User!]! @variable(subgraph: "Accounts", name: "ids", argument: "ids") @resolver(subgraph: "Accounts", select: "{ usersById(ids: $ids) }", arguments: [ { name: "ids", type: "[ID!]!" } ])
Expand Down Expand Up @@ -197,7 +199,7 @@ scalar Date
```json
{
"Name": "Accounts",
"Schema": "schema {\n query: Query\n mutation: Mutation\n}\n\n\"The node interface is implemented by entities that have a global unique identifier.\"\ninterface Node {\n id: ID!\n}\n\ntype Query {\n \"Fetches an object given its ID.\"\n node(\"ID of the object.\" id: ID!): Node\n \"Lookup nodes by a list of IDs.\"\n nodes(\"The list of node IDs.\" ids: [ID!]!): [Node]!\n users: [User!]!\n userById(id: ID!): User\n usersById(ids: [ID!]!): [User!]!\n errorField: String\n viewer: Viewer!\n}\n\ntype Mutation {\n addUser(input: AddUserInput!): AddUserPayload!\n}\n\n\"The `Date` scalar represents an ISO-8601 compliant date type.\"\nscalar Date\n\ntype Viewer {\n user: User\n data: SomeData!\n}\n\ntype User implements Node {\n errorField: String\n id: ID!\n name: String!\n birthdate: Date!\n username: String!\n}\n\ntype SomeData {\n accountValue: String!\n}\n\ninput AddUserInput {\n name: String!\n username: String!\n birthdate: Date!\n}\n\ntype AddUserPayload {\n user: User\n}",
"Schema": "schema {\n query: Query\n mutation: Mutation\n}\n\n\"The node interface is implemented by entities that have a global unique identifier.\"\ninterface Node {\n id: ID!\n}\n\ntype Query {\n \"Fetches an object given its ID.\"\n node(\"ID of the object.\" id: ID!): Node\n \"Lookup nodes by a list of IDs.\"\n nodes(\"The list of node IDs.\" ids: [ID!]!): [Node]!\n users: [User!]!\n userById(id: ID!): User\n usersById(ids: [ID!]!): [User!]!\n errorField: String\n testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int\n viewer: Viewer!\n}\n\ntype Mutation {\n addUser(input: AddUserInput!): AddUserPayload!\n}\n\n\"The `Date` scalar represents an ISO-8601 compliant date type.\"\nscalar Date\n\ntype User implements Node {\n errorField: String\n id: ID!\n name: String!\n birthdate: Date!\n username: String!\n}\n\ntype Viewer {\n user: User\n data: SomeData!\n}\n\ntype SomeData {\n accountValue: String!\n}\n\ninput AddUserInput {\n name: String!\n username: String!\n birthdate: Date!\n}\n\ntype AddUserPayload {\n user: User\n}",
"Extensions": [
"extend type Query {\n userById(id: ID!\n @is(field: \"id\")): User!\n usersById(ids: [ID!]!\n @is(field: \"id\")): [User!]!\n}"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ schema {

type Query {
errorField: String
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
userById(id: ID!): User
users: [User!]!
usersById(ids: [ID!]!): [User!]!
Expand Down Expand Up @@ -66,6 +67,7 @@ schema @fusion(version: 1) @transport(subgraph: "Accounts", group: "Fusion", loc

type Query {
errorField: String @resolver(subgraph: "Accounts", select: "{ errorField }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int @variable(subgraph: "Accounts", name: "first", argument: "first") @variable(subgraph: "Accounts", name: "second", argument: "second") @resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
userById(id: ID!): User @variable(subgraph: "Accounts", name: "id", argument: "id") @resolver(subgraph: "Accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
users: [User!]! @resolver(subgraph: "Accounts", select: "{ users }")
usersById(ids: [ID!]!): [User!]! @variable(subgraph: "Accounts", name: "ids", argument: "ids") @resolver(subgraph: "Accounts", select: "{ usersById(ids: $ids) }", arguments: [ { name: "ids", type: "[ID!]!" } ])
Expand Down Expand Up @@ -117,7 +119,7 @@ scalar Date
```json
{
"Name": "Accounts",
"Schema": "schema {\n query: Query\n mutation: Mutation\n}\n\n\"The node interface is implemented by entities that have a global unique identifier.\"\ninterface Node {\n id: ID!\n}\n\ntype Query {\n \"Fetches an object given its ID.\"\n node(\"ID of the object.\" id: ID!): Node\n \"Lookup nodes by a list of IDs.\"\n nodes(\"The list of node IDs.\" ids: [ID!]!): [Node]!\n users: [User!]!\n userById(id: ID!): User\n usersById(ids: [ID!]!): [User!]!\n errorField: String\n viewer: Viewer!\n}\n\ntype Mutation {\n addUser(input: AddUserInput!): AddUserPayload!\n}\n\n\"The `Date` scalar represents an ISO-8601 compliant date type.\"\nscalar Date\n\ntype Viewer {\n user: User\n data: SomeData!\n}\n\ntype User implements Node {\n errorField: String\n id: ID!\n name: String!\n birthdate: Date!\n username: String!\n}\n\ntype SomeData {\n accountValue: String!\n}\n\ninput AddUserInput {\n name: String!\n username: String!\n birthdate: Date!\n}\n\ntype AddUserPayload {\n user: User\n}",
"Schema": "schema {\n query: Query\n mutation: Mutation\n}\n\n\"The node interface is implemented by entities that have a global unique identifier.\"\ninterface Node {\n id: ID!\n}\n\ntype Query {\n \"Fetches an object given its ID.\"\n node(\"ID of the object.\" id: ID!): Node\n \"Lookup nodes by a list of IDs.\"\n nodes(\"The list of node IDs.\" ids: [ID!]!): [Node]!\n users: [User!]!\n userById(id: ID!): User\n usersById(ids: [ID!]!): [User!]!\n errorField: String\n testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int\n viewer: Viewer!\n}\n\ntype Mutation {\n addUser(input: AddUserInput!): AddUserPayload!\n}\n\n\"The `Date` scalar represents an ISO-8601 compliant date type.\"\nscalar Date\n\ntype User implements Node {\n errorField: String\n id: ID!\n name: String!\n birthdate: Date!\n username: String!\n}\n\ntype Viewer {\n user: User\n data: SomeData!\n}\n\ntype SomeData {\n accountValue: String!\n}\n\ninput AddUserInput {\n name: String!\n username: String!\n birthdate: Date!\n}\n\ntype AddUserPayload {\n user: User\n}",
"Extensions": [
"extend type Query {\n userById(id: ID!\n @is(field: \"id\")): User!\n usersById(ids: [ID!]!\n @is(field: \"id\")): [User!]!\n}"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Query {
userById(id: ID!): User
usersById(ids: [ID!]!): [User!]!
errorField: String
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
viewer: Viewer!
}

Expand All @@ -34,11 +35,6 @@ type Mutation {
"The `Date` scalar represents an ISO-8601 compliant date type."
scalar Date

type Viewer {
user: User
data: SomeData!
}

type User implements Node {
errorField: String
id: ID!
Expand All @@ -47,6 +43,11 @@ type User implements Node {
username: String!
}

type Viewer {
user: User
data: SomeData!
}

type SomeData {
accountValue: String!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Query {
userById(id: ID!): User
usersById(ids: [ID!]!): [User!]!
errorField: String
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
viewer: Viewer!
}

Expand All @@ -34,11 +35,6 @@ type Mutation {
"The `Date` scalar represents an ISO-8601 compliant date type."
scalar Date

type Viewer {
user: User
data: SomeData!
}

type User implements Node {
errorField: String
id: ID!
Expand All @@ -47,6 +43,11 @@ type User implements Node {
username: String!
}

type Viewer {
user: User
data: SomeData!
}

type SomeData {
accountValue: String!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type Query {
@resolver(subgraph: "Reviews", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
@variable(subgraph: "Accounts", name: "first", argument: "first")
@variable(subgraph: "Accounts", name: "second", argument: "second")
@resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
userById(id: ID!): User
@variable(subgraph: "Accounts", name: "id", argument: "id")
@resolver(subgraph: "Accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ type Query {
@resolver(subgraph: "Reviews2", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews2", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
@variable(subgraph: "Accounts", name: "first", argument: "first")
@variable(subgraph: "Accounts", name: "second", argument: "second")
@resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
topProducts(first: Int!): [Product!]!
@variable(subgraph: "Products", name: "first", argument: "first")
@resolver(subgraph: "Products", select: "{ topProducts(first: $first) }", arguments: [ { name: "first", type: "Int!" } ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type Query {
@resolver(subgraph: "Reviews", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
@variable(subgraph: "Accounts", name: "first", argument: "first")
@variable(subgraph: "Accounts", name: "second", argument: "second")
@resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
userById(id: ID!): User
@variable(subgraph: "Accounts", name: "id", argument: "id")
@resolver(subgraph: "Accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ type Query {
@resolver(subgraph: "Reviews", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
@variable(subgraph: "Accounts", name: "first", argument: "first")
@variable(subgraph: "Accounts", name: "second", argument: "second")
@resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
topProducts(first: Int!): [Product!]!
@variable(subgraph: "Products", name: "first", argument: "first")
@resolver(subgraph: "Products", select: "{ topProducts(first: $first) }", arguments: [ { name: "first", type: "Int!" } ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type Query {
@resolver(subgraph: "Reviews", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
@variable(subgraph: "Accounts", name: "first", argument: "first")
@variable(subgraph: "Accounts", name: "second", argument: "second")
@resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
topProducts(first: Int!): [Product!]!
@variable(subgraph: "Products", name: "first", argument: "first")
@resolver(subgraph: "Products", select: "{ topProducts(first: $first) }", arguments: [ { name: "first", type: "Int!" } ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ type Query {
@resolver(subgraph: "Reviews", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
@variable(subgraph: "Accounts", name: "first", argument: "first")
@variable(subgraph: "Accounts", name: "second", argument: "second")
@resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
topProducts(first: Int!): [Product!]!
@variable(subgraph: "Products", name: "first", argument: "first")
@resolver(subgraph: "Products", select: "{ topProducts(first: $first) }", arguments: [ { name: "first", type: "Int!" } ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type Query {
@resolver(subgraph: "Reviews", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
@variable(subgraph: "Accounts", name: "first", argument: "first")
@variable(subgraph: "Accounts", name: "second", argument: "second")
@resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
userById(id: ID!): User
@variable(subgraph: "Accounts", name: "id", argument: "id")
@resolver(subgraph: "Accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ type Query {
@resolver(subgraph: "Reviews", select: "{ reviewOrAuthor }")
reviews: [Review!]!
@resolver(subgraph: "Reviews", select: "{ reviews }")
testWithTwoArgumentsDifferingNullability(first: Int! second: Int): Int
@variable(subgraph: "Accounts", name: "first", argument: "first")
@variable(subgraph: "Accounts", name: "second", argument: "second")
@resolver(subgraph: "Accounts", select: "{ testWithTwoArgumentsDifferingNullability(first: $first, second: $second) }", arguments: [ { name: "first", type: "Int!" }, { name: "second", type: "Int" } ])
topProducts(first: Int!): [Product!]!
@variable(subgraph: "Products", name: "first", argument: "first")
@resolver(subgraph: "Products", select: "{ topProducts(first: $first) }", arguments: [ { name: "first", type: "Int!" } ])
Expand Down
Loading
Loading