Fix __typename rebasing for interface objects#2886
Merged
sachindshinde merged 3 commits intomainfrom Dec 8, 2023
Merged
Conversation
🦋 Changeset detectedLatest commit: bbaf0c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for apollo-federation-docs canceled.
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
… being rebased onto a parent type whose runtime types contain at least one interface object
fe2f19b to
bbaf0c2
Compare
clenfest
approved these changes
Dec 8, 2023
dariuszkuc
pushed a commit
that referenced
this pull request
Dec 11, 2023
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @apollo/composition@2.6.2 ### Patch Changes - Updated dependencies \[[`7b5b836d15247c997712a47847f603aa5887312e`](7b5b836), [`74ca7dd617927a20d79b824851f7651ef3c40a4e`](74ca7dd), [`3f7392b84f8b626b248b59ce81f193d0f0272045`](3f7392b)]: - @apollo/federation-internals@2.6.2 - @apollo/query-graphs@2.6.2 ## @apollo/gateway@2.6.2 ### Patch Changes - Updated dependencies \[[`7b5b836d15247c997712a47847f603aa5887312e`](7b5b836), [`74ca7dd617927a20d79b824851f7651ef3c40a4e`](74ca7dd), [`ffe67dfbdb77d15dde2ab6dee66dba05c7b5c037`](ffe67df)]: - @apollo/federation-internals@2.6.2 - @apollo/query-planner@2.6.2 - @apollo/composition@2.6.2 ## @apollo/federation-internals@2.6.2 ### Patch Changes - Avoid `>=` comparison for `FeatureVersion` objects ([#2883](#2883)) - Fix query planning bug where `__typename` on interface object types in named fragments can cause query plan execution to fail. ([#2886](#2886)) ([#2886](#2886)) ## @apollo/query-graphs@2.6.2 ### Patch Changes - fix: handle directive conditions on fragments when building query graphs ([#2875](#2875)) This fix addresses issues with handling fragments when they specify directive conditions: - when exploding the types we were not propagating directive conditions - when processing fragment that specifies super type of an existing type and also specifies directive condition, we were incorrectly preserving the unnecessary type condition. This type condition was problematic as it could be referencing types from supergraph that were not available in the local schema. Instead, we now drop the redundant type condition and only preserve the directives (if specified). - Updated dependencies \[[`7b5b836d15247c997712a47847f603aa5887312e`](7b5b836), [`74ca7dd617927a20d79b824851f7651ef3c40a4e`](74ca7dd)]: - @apollo/federation-internals@2.6.2 ## @apollo/query-planner@2.6.2 ### Patch Changes - Add a limit to the number of options for a selection. In some cases, we will generate a lot of possible paths to access a field. There is a process to remove redundant paths, but when the list is too large, that process gets very expensive. To prevent that, we introduce an optional limit that will reject the query if too many paths are generated ([#2880](#2880)) - Updated dependencies \[[`7b5b836d15247c997712a47847f603aa5887312e`](7b5b836), [`74ca7dd617927a20d79b824851f7651ef3c40a4e`](74ca7dd), [`3f7392b84f8b626b248b59ce81f193d0f0272045`](3f7392b)]: - @apollo/federation-internals@2.6.2 - @apollo/query-graphs@2.6.2 ## @apollo/subgraph@2.6.2 ### Patch Changes - Updated dependencies \[[`7b5b836d15247c997712a47847f603aa5887312e`](7b5b836), [`74ca7dd617927a20d79b824851f7651ef3c40a4e`](74ca7dd)]: - @apollo/federation-internals@2.6.2 ## apollo-federation-integration-testsuite@2.6.2 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Merged
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We should never query
__typenamefrom a subgraph for an object type marked@interfaceObject, as the value we get back will always be wrong. Normally, we prevent this by not having a__typenameedge in the federated query graph.However, during the optimization where we try to reuse existing named fragments, we rebase them from the API schema onto the subgraph schemas. We usually ignore selections where this leads to invalidity (e.g. fields or types that don't exist in the subgraph schema), but the code doesn't currently view the
__typenamefield being rebased onto an interface object as invalid. This has led to bugs where named fragments containing__typenameaccidentally cause it to be queried on interface objects in subgraph queries.This PR changes
Field.rebaseOn()such that__typenamebeing rebased onto a parent type that is an interface object is considered invalid. Additionally, if the parent type is an abstract type, and that abstract type could possibly be an interface object type at runtime, then this is additionally considered invalid.