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

nonreactive directive on a defer fragment #11616

Open
thomaswelton opened this issue Feb 22, 2024 · 1 comment
Open

nonreactive directive on a defer fragment #11616

thomaswelton opened this issue Feb 22, 2024 · 1 comment
Labels
🐞 bug 🔍 investigate Investigate further

Comments

@thomaswelton
Copy link

Issue Description

The nonreactive directive is not compatible with deferred fragments for the initial fetch of a query.

Given this query

fragment NameFragment on Playlist {
    name
  }

query GetPlaylists {
    featuredPlaylists {
      edges {
        node {
          id
          ... @defer {
            ...NameFragment @nonreactive
          }
        }
      }
    }
  }

I would expect that the query results would contain my array of nodes with the id parameter loaded.
Then when the defer data is loaded incrementally I'd expect that the nodes array would be referentially stable due to the fact that the NameFragement is @nonreactive, but this is not the case.

In our real world case we are fetching an array of results to show on a list view and map. Some of the data in these results is slow to load so we have used defer.
However the result is not referentially stable which is causing some performance issues where our whole list is rerendered multiple times.

See also a thread on discord

Link to Reproduction

https://github.com/thomaswelton/react-apollo-error-template/tree/defer-nonreactive

Reproduction Steps

Run the development server locally.
See that the heading on the page contains a count of the amount of times that the query results array has changed.
See that once the deffered data loads the render count is 2 instead of the expected 1.

@apollo/client version

3.9.4

@jerelmiller jerelmiller added 🔍 investigate Investigate further 🏓 awaiting-team-response requires input from the apollo team labels Feb 22, 2024
@jerelmiller
Copy link
Member

Thanks for the report and reproduction! We'll get to this when we can 🙂

@jerelmiller jerelmiller added 🐞 bug 💸 caching and removed 🏓 awaiting-team-response requires input from the apollo team 💸 caching labels Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug 🔍 investigate Investigate further
Projects
None yet
Development

No branches or pull requests

2 participants