apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.38k stars 2.66k forks source link

`useFragment` doesn't respect the `@nonreactive` directive #11785

Closed broyde closed 6 months ago

broyde commented 7 months ago

Issue Description

  1. Create a fragment with @nonreactive field, write some data into the cache.
  2. Use this fragment in useFragment.
  3. Update the value of @nonreactive field.

Expected behavior: useFragment does not react to such changes. Actual behavior: useFragment triggers update in the same way as it does without @nonreactive directive. Test example: https://github.com/broyde/apollo-use-fragment-nonreactive/blob/main/test.js

FYI: I've noticed the same behavior of useQuery, but only in test environment (see test: https://github.com/broyde/apollo-query-nonreactive/blob/main/test.js). In real browser useQuery does not react to such changes, but useFragment does.

Link to Reproduction

https://github.com/broyde/apollo-use-fragment-nonreactive

Reproduction Steps

No response

@apollo/client version

3.9.11

jerelmiller commented 7 months ago

Hey @broyde 👋

Thanks for the report! Initially the @nonreactive directive was meant for use with queries, not fragments, but we talked about this more as a team and think this change makes sense. We re-read through our docs and realized that its a bit ambiguous on the original intention so we plan to make a temporary docs update until we can get this functionality in place.

We are releasing 3.10 this week and will try and target this change for one of the 3.10.x patch releases.

github-actions[bot] commented 6 months ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

github-actions[bot] commented 5 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.