fix: Return root when parts of a query with deferred fragment#2188
fix: Return root when parts of a query with deferred fragment#2188
Conversation
apollo-router/src/spec/query.rs
Outdated
| } | ||
| // Detect if root __typename is asked in the original query (the qp doesn't put root __typename in subselections) | ||
| // cf https://github.com/apollographql/router/issues/1677 | ||
| let operation_kind_if_root_typename = self.operations.get(0).and_then(|op| { |
There was a problem hiding this comment.
could this be moved (again, sorry 🙏) under the match branch on Selection::Field?
The current operation is already selected at line 670 (and it might not be the first one in the list)
There was a problem hiding this comment.
I think it could be fixed for the InlineFragment and FragmentSpread as well, by going through the selection set before calling apply_selection_set. That would not work with nested fragments though
|
DRAFT because it should be fixed by #2109. I deleted the logic, just kept the test |
the deferred node's path now contains fragments to help in query reconstruction, and the flatten elements are not present anymore
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
|
@Geal ready to review |
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
0fe93ee to
ba258f9
Compare
| .any(|f| f.is_typename_field()) | ||
| .then(|| *op.kind()) | ||
| }); | ||
| if let Some(operation_kind) = operation_kind_if_root_typename { |
There was a problem hiding this comment.
I think this should check that the defer fragment is at the root, right? if you have query { something ...@defer { __typename id} } would "__typename": "Query" be added to the root of output?
There was a problem hiding this comment.
Yes Check the tests. I added a similar test
close #1677