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

Disabling normalization by query and not by object #315

Open
eltonio450 opened this issue Oct 1, 2021 · 2 comments
Open

Disabling normalization by query and not by object #315

eltonio450 opened this issue Oct 1, 2021 · 2 comments
Labels
🏎️ performance Feature requests related to performance enhancements

Comments

@eltonio450
Copy link

eltonio450 commented Oct 1, 2021

Why ?

Our app is (as many ?) working with objects screen and dashboard with lists of those objects. Lists are quite big (~200/500 objects), and normalization brings a lot of issues:

  • performance issues, when reconstructing larges lists from the cache
  • cache miss issues, when fragments are not overlapping (e.g. fragments for the list and for the object are not a subset of each other) => cache is invalidated, and we have to refetch everything if we go from list => objects or objects => lists (both ways !)
  • other weird bugs such as Slow overlapping queries due to MissingFieldError invariants apollo-client#8707

It turns out normalization does not bring a lot in terms of performance/speed for queries with large lists, because we have to refetch the lists regularly anyway (if an item is added, etc.). Refetch queries or regular polling are relevant in many cases

What ?

We would like to have a way to disable normalization recursively for our list queries. We would like to keep the cache for those queries, but without border effects. The cache could store them as is, as a whole.

How ?

I tried to disable the normalization for our "ObjectConnection" for example, but "Object" is still normalized

The same behaviour could maybe be achieved with two apollo clients (one with normalization and one without) but I am not really sure on this, and it brings also its challenges

I am not sure exactly how this could be achieved technically, but I feel that in terms of API, it could be added to useQuery options, for example "disableNormalization" and then passed to InMemoryCache

Thank you !

@eltonio450
Copy link
Author

eltonio450 commented Oct 2, 2021

Another feature that we had to disable : prefetching data for the next screen :

When we are on a dashboard with large lists, we used to prefetch data of the next page on mouse hover, but a the list is reconstruted every time there is an update on any object of the list, the interface just freezes

=> the goal is really to have an apollo client that does not take into account lists when it comes to normalization

@jerelmiller
Copy link
Member

Hey @eltonio450 👋

We've got a feature coming in 3.8 that allows you to use a @nonreactive directive to allow you to control when a parent component should rerender based on changes to the cache. This combined with useFragment is meant to help address performance concerns with large lists that may have lots of cache updates over time.

I'll leave this issue open, but I'd love for you to try out this solution once released to see if this helps address some of your concern.

Thanks for raising this idea!

@jerelmiller jerelmiller added the 🏎️ performance Feature requests related to performance enhancements label Apr 6, 2023
@jerelmiller jerelmiller removed the project-apollo-client (legacy) LEGACY TAG DO NOT USE label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏎️ performance Feature requests related to performance enhancements
Projects
None yet
Development

No branches or pull requests

3 participants