-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Gateway over-merging fields of unioned types #3581
Conversation
Hi @trevor-scheer - I think I have a fix for this. Let me know if this passes your test. f2cc553 |
The groupByResponseName function was insufficient for determining the merge condition for selections. The parent type name is also required for the merge condition, as it's possible for them to differ.
Hey @stejas, thanks for taking a stab at this one! In your test, |
Hi @trevor-scheer - Just looked at your fix! If I understand correctly, aren't our fixes effectively same? I am passing |
This commit cleans up and simplifies the approach taken by #3581 to prevent the gateway from over-merging fields of unioned types. The correct information and groupings were already present in the affected code, they just needed to be utilized correctly. Specifically, the internal for loop yielding `fieldsForParentType` was not being used - the less specifically grouped `fieldsForResponseName` was. Co-authored-by: Tejas Shikhare <tshikhare@netflix.com>
This commit cleans up and simplifies the approach taken by #3581 to prevent the gateway from over-merging fields of unioned types. The correct information and groupings were already present in the affected code, they just needed to be utilized correctly. Specifically, the internal for loop yielding `fieldsForParentType` was not being used - the less specifically grouped `fieldsForResponseName` was. Co-authored-by: Tejas Shikhare <tshikhare@netflix.com>
@stejas you're right! My apologies, I was a bit excited to land this fix and could have looked a bit more closely (though I recall running those changes previously against my test and seeing failures 🤔 I'll chalk it up to an error on my end, since your changes pass my test now). I'll await your response on #3616 about landing your simplified changes. |
This commit cleans up and simplifies the approach taken by #3581 to prevent the gateway from over-merging fields of unioned types. The correct information and groupings were already present in the affected code, they just needed to be utilized correctly. Specifically, the internal for loop yielding `fieldsForParentType` was not being used - the less specifically grouped `fieldsForResponseName` was. Co-authored-by: Tejas Shikhare <tshikhare@netflix.com>
…rver#3581) Group fields by response name AND parent type The groupByResponseName function was insufficient for determining the merge condition for selections. The parent type name is also required for the merge condition, as it's possible for them to differ. Apollo-Orig-Commit-AS: apollographql/apollo-server@c17c7bb
This commit cleans up and simplifies the approach taken by apollographql/apollo-server#3581 to prevent the gateway from over-merging fields of unioned types. The correct information and groupings were already present in the affected code, they just needed to be utilized correctly. Specifically, the internal for loop yielding `fieldsForParentType` was not being used - the less specifically grouped `fieldsForResponseName` was. Co-authored-by: Tejas Shikhare <tshikhare@netflix.com> Apollo-Orig-Commit-AS: apollographql/apollo-server@61e6941
This PR adds some granularity to how fields are keyed when we group them within a selection set. Previously, the field name was considered sufficient for merging selections (and it almost always is!). However, in the case that the
parentType
of these same-named fields is different, we most certainly should not group selections as it will result in invalid query plans.The new test illustrates this edge case via two
union
ed types that share a same top-level field name. The gateway was incorrectly grouping these separate fields into the sameselectionSet
under themedia
field. By keying onparentType:responseName
instead, the gateway will know better than to group two distinctmedia
fields of different types.