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

Allow registering named fragments with InMemoryCache to support using ...FragmentName in queries without redeclaring FragmentName in every query #9764

Merged
merged 10 commits into from
Sep 21, 2022

Commits on Sep 21, 2022

  1. 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.
    benjamn committed Sep 21, 2022
    Configuration menu
    Copy the full SHA
    e3205d7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    570dbaa View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c955935 View commit details
    Browse the repository at this point in the history
  4. 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.
    benjamn committed Sep 21, 2022
    Configuration menu
    Copy the full SHA
    01a22ba View commit details
    Browse the repository at this point in the history
  5. 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).
    benjamn committed Sep 21, 2022
    Configuration menu
    Copy the full SHA
    50f917a View commit details
    Browse the repository at this point in the history
  6. 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.
    benjamn committed Sep 21, 2022
    Configuration menu
    Copy the full SHA
    abecb11 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    52c7f61 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    32b4acd View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    5c6ae24 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    dc8b8ba View commit details
    Browse the repository at this point in the history