Skip to content
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

duplicate GraphQL Variables for compound queries #225

Closed
mdugue opened this issue Nov 30, 2024 · 0 comments · Fixed by #243
Closed

duplicate GraphQL Variables for compound queries #225

mdugue opened this issue Nov 30, 2024 · 0 comments · Fixed by #243

Comments

@mdugue
Copy link

mdugue commented Nov 30, 2024

First of all, great work on grahql mesh and hive gateway. I'd love to help making it a robust open source solution. Hence I'll try to share some broken edge case I stumbled upon.

Hive Gateway seems to forward broken variables to subgraphs when variables are optional and not provided by the query.

Example

this works fine

query TestOK($a:String, $b:String) {
  params1(a: $a, b:$b)
}

#variables
{}

this breaks

query TestBroken($a:String, $b:String) {
  params1(a: $a, b:$b)
  o: params1(a: $a, b:$b)
}

#variables
{}

Apparently the variables get repeatedly appended for each top-level query field, so that the subgraph receives the following query:

"query TestBroken($a:String$b:String$a:String$b:String){_0___typename:__typename _0_params1:params1(a:$a b:$b)_1___typename:__typename _1_params1:params1(a:$a b:$b)}"

Note the duplication in the variables $a:String$b:String$a:String$b:String

Observations

  • the problematic query in is correctly forwarded if variables are set, eg. {"a": "foo"} or even {"a": null}
  • if 3 top level query fields are set, the variable definition is also 3x
  • it does not make a difference if the used top level fields are the same with an alias or another field

In case you need some reproduction deployment I'm more than happy to provide one, but I'm not sure what to use as I assume CodeSandbox will not work easily. Do you have any guidelines therefore?

Thanks a lot in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant