-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
RFC (Graphcache): Change SerializedEntries to provide Map to storage adapters #3425
Comments
Running into this properties limit is something that is happening to us in production. If this a change y'all would be interested interested I'd be happy to own the implementation as I'll likely be making this patch regardless. Mainly would like to know if I should bother going through the effort of updating storage adapters urql ships and making a merge-able PR. |
Swap SerializedEntries to pass data as a Map instead plain object. The main motivation for this change is to support metro's low object properties limit. facebook/hermes#851 Urql issue: urql-graphql#3425
Swap SerializedEntries to pass data as a Map instead plain object. The main motivation for this change is to support metro's low object properties limit. facebook/hermes#851 Urql issue: urql-graphql#3425
I think the problems here we'll run into are that the format isn't detached from Graphcache of course: urql/exchanges/graphcache/src/store/data.ts Lines 610 to 657 in 8ff4e3e
For context (i.e. readers who'll be following this thread passively), this means that we'll have to make all storages incompatible and this will break any offline caches that someone may have already built-up. In short, this is definitely a big change, and a breaking change, if we consider storages to be a public interface; personally, I do, but this also depends on how many custom storages we expect people to have written, re. urql/exchanges/graphcache/src/types.ts Lines 933 to 935 in 8ff4e3e
Currently, the problem of storage persistence runs rather deep and I'd consider the current implementation optimised only for the format it has.
The reason this is done this way (besides reading from the layers in the "ground truth" order), is to not make writing more expensive than it is. We don't want the write performance to be impacted, which is why a buffer is created rather than "streaming" the changed values into a buffer/storage. The alternative of maps is interesting, but indeed causes serialisation issues. Hence, it doesn't actually solve the problem but pushes it onwards to storages. This increases complexity for storages. So, the format per se isn't necessarily the problem:
So, this does open up more options and more aggressive changes than just switching to |
Firstly, thank you for the detailed response and all the work on this library ❤️ I did get Graphcahce working with Coming up with an interface that would "chunk" by default would be awesome, especially if it can provide Graphcahce with performance benefits without significantly increasing complexity on |
Summary
Change SerializedEntries to return a
Map
instead of an object.This will prevent react-native clients using Hermes from running up against 196607 properties limit and breaking caching. facebook/hermes#851
Proposed Solution
Change the type of
SerializedEntries
toSerializedEntries = Map<string, string | undefined>;
Downsides
SerializedEntries
can no longer beJSON.strinigify
'ed without using the replacement functionThe text was updated successfully, but these errors were encountered: