-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow registering named fragments with InMemoryCache
to support using ...FragmentName
in queries without redeclaring FragmentName
in every query
#9764
Commits on Sep 21, 2022
-
Call cache.transformForLink before each link execution.
This is not a disruptive change for InMemoryCache, since it uses the default implementation of tranformForLink (inherited from ApolloCache), which simply returns the given document. If you're using a different ApolloCache implementation that has a custom transformForLink implementation, this new behavior should be more convenient and flexible, but you should probably double-check that your transformForLink method is suitably cached/idempotent, so multiple calls with the same input document return the same (===) transformed document.
Configuration menu - View commit details
-
Copy full SHA for e3205d7 - Browse repository at this point
Copy the full SHA e3205d7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 570dbaa - Browse repository at this point
Copy the full SHA 570dbaaView commit details -
Configuration menu - View commit details
-
Copy full SHA for c955935 - Browse repository at this point
Copy the full SHA c955935View commit details -
Implement a FragmentRegistry for registering named fragments.
This is just one implementation of a FragmentRegistry that could be provided to InMemoryCache to fill in missing fragment declarations in transformForLink. Learning from past mistakes, we will avoid referring directly to this particular implementation of FragmentRegistry within the InMemoryCache implementation, since that forces the full FragmentRegistry implementation to be bundled even when it is not used.
Configuration menu - View commit details
-
Copy full SHA for 01a22ba - Browse repository at this point
Copy the full SHA 01a22baView commit details -
Provide abstract FragmentRegistryAPI TypeScript interface.
As long as InMemoryCache uses only this TypeScript interface when handling FragmentRegistry configurations, any implementation can be swapped in without also paying for the bundle size of the default implementation (the FragmentRegistry class).
Configuration menu - View commit details
-
Copy full SHA for 50f917a - Browse repository at this point
Copy the full SHA 50f917aView commit details -
Use InMemoryCache#transformForLink to supply missing fragments.
Since these changes do not include any calls to createFragmentRegistry, the FragmentRegistry class implementation remains optional and thus tree-shakable if unused.
Configuration menu - View commit details
-
Copy full SHA for abecb11 - Browse repository at this point
Copy the full SHA abecb11View commit details -
Configuration menu - View commit details
-
Copy full SHA for 52c7f61 - Browse repository at this point
Copy the full SHA 52c7f61View commit details -
Configuration menu - View commit details
-
Copy full SHA for 32b4acd - Browse repository at this point
Copy the full SHA 32b4acdView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5c6ae24 - Browse repository at this point
Copy the full SHA 5c6ae24View commit details -
Configuration menu - View commit details
-
Copy full SHA for dc8b8ba - Browse repository at this point
Copy the full SHA dc8b8baView commit details