Incorrect query AST when there are duplicated nested fields with different selection sets
See original GitHub issueWhen resolving a query with duplicated nested fields with different selection sets, only the first selection set is available to the resolver info AST.
Given the following query:
query {
person {
firstName
}
person {
lastName
}
}
When inspecting the AST available in info.field_nodes
, only firstName
will be available.
Expected behavior: the person resolver is called once, and firstName
and lastName
are available in the AST. Or, the person resolver gets called twice: first with firstName
in the AST and the second with lastName
in the AST.
Current behavior: the person resolver is called once, and only with firstName
.
This is a problem, because I want to be able to know all the full selection set of a queried field for optimization purposes. This bug is especially puzzling because the data returned is in the correct shape with the merged selection sets, yet it seems like the resolver is only returning incomplete data. Any insight on this issue would be greatly appreciated!
Here is a minimal reproducible example: https://gist.github.com/fireteam99/20be417e397a1672380e33b18164ec12.
- Version: 3.1
- Platform: MacOS/Linux
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
@erikwrede @Cito, thank you for spending the time to look into this issue! I did not realize that they would be in the other items in
field_nodes
. @Cito the solution you presented is exactly what I was looking for!@erikwrede I currently do not see a better approach, but I also do not understand the need for doing this.
To sum it up, the problem in the code used by @fireteam99 was that it only inspected the first item in
field_nodes
, but not the other ones. It can be fixed like this: