Skip to content

Releases: apollographql/apollo-client

3.5.x

22 Nov 17:52
524aba4
Compare
Choose a tag to compare

Apollo Client 3.5.5 (2021-11-23)

Bug Fixes

  • Remove printer: Printer positional parameter from publicly-exported selectHttpOptionsAndBody function, whose addition in #8699 was a breaking change (starting in Apollo Client 3.5.0) for direct consumers of selectHttpOptionsAndBody.
    @benjamn in #9103

Apollo Client 3.5.4 (2021-11-19)

Notices

  • [Relevant if you use Apollo Client with React Native] Since Apollo Client v3.5.0, CommonJS bundles provided by @apollo/client use a .cjs file extension rather than .cjs.js, so Node.js won't interpret them as ECMAScript modules. While this change should be an implementation detail, it may cause problems for the Metro bundler used by React Native, whose resolver.sourceExts configuration does not include the cjs extension by default.

    As a workaround until this issue is resolved, you can configure Metro to understand the .cjs file extension by creating a metro.config.js file in the root of your React Native project:

    const { getDefaultConfig } = require("metro-config");
    const { resolver: defaultResolver } = getDefaultConfig.getDefaultValues();
    exports.resolver = {
      ...defaultResolver,
      sourceExts: [
        ...defaultResolver.sourceExts,
        "cjs",
      ],
    };

Improvements

  • Restore the ability to pass onError() and onCompleted() to the mutation execution function.
    @brainkim in #9076

  • Work around webpack 5 errors of the form

    The request 'ts-invariant/process' failed to resolve only because it was resolved as fully specified
    

    by ensuring import ... from 'ts-invariant/process' is internally written to import ... from 'ts-invariant/process/index.js'.
    @benjamn in #9083

Apollo Client 3.5.3 (2021-11-17)

  • Avoid rewriting non-relative imported module specifiers in config/rewriteModuleIds.ts script, thereby allowing bundlers to resolve those imports as they see fit.
    @benjamn in #9073

  • Ensure only current file is matched when running VSCode debugger.
    @eps1lon in #9050

Apollo Client 3.5.2 (2021-11-10)

  • Fix useMutation execute function returning non-identical execution functions when passing similar options.
    @brainkim in #9093

Apollo Client 3.5.1 (2021-11-09)

  • Remove npm from dependencies, and avoid referencing graphql-js enum value.
    @brainkim in #9030

Apollo Client 3.5.0 (2021-11-08)

Improvements

  • Add updateQuery and updateFragment methods to ApolloCache, simplifying common readQuery/writeQuery cache update patterns.
    @wassim-k in #8382

  • Field directives and their arguments can now be included along with field argument names when using field policy keyArgs: [...] notation. For example, if you have a Query.feed field that takes an argument called type and uses a @connection(key:...) directive to keep feed data from different queries separate within the cache, you might configure both using the following InMemoryCache field policy:

    new InMemoryCache({
      typePolicies: {
        Query: {
          fields: {
            feed: {
              keyArgs: ["type", "@connection", ["key"]],
            },
          },
        },
      },
    })

    @benjamn in #8678

  • Report single MissingFieldError instead of a potentially very large MissingFieldError[] array for incomplete cache reads, improving performance and memory usage.
    @benjamn in #8734

  • When writing results into InMemoryCache, each written object is now identified using policies.identify after traversing the fields of the object (rather than before), simplifying identification and reducing duplicate work. If you have custom keyFields functions, they still receive the raw result object as their first parameter, but the KeyFieldsContext parameter now provides context.storeObject (the StoreObject just processed by processSelectionSet) and context.readField (a helper function for reading fields from context.storeObject and any References it might contain, similar to readField for read, merge, and cache.modify functions).
    @benjamn in #8996

  • Ensure cache.identify never throws when primary key fields are missing, and include the source object in the error message when keyFields processing fails.
    @benjamn in #8679

  • The HttpLink constructor now accepts an optional print function that can be used to customize how GraphQL DocumentNode objects are transformed back into strings before they are sent over the network.
    @sarahgp in #8699

  • Make @apollo/client/testing a fully-fledged, independent entry point, instead of re-exporting @apollo/client/utilities/testing (which was never an entry point and no longer exists).
    @benjamn in #8769

  • A new nested entry point called @apollo/client/testing/core has been created. Importing from this entry point instead of @apollo/client/testing excludes any React-related dependencies.
    @wassim-k in #8687

  • Make cache.batch return the result of calling the options.update function.
    @benjamn in #8696

  • The NetworkError and ErrorResponse types have been changed to align more closely.
    @korywka in #8424

  • Include graphql@16 in peer deps.
    @brainkim in #8997

  • Update zen-observable-ts to eliminate transitive dependency on @types/zen-observable.
    @benjamn in #8695

React Refactoring

Improvements (due to @brainkim in #8875):

  • The useLazyQuery function now returns a promise with the result.
  • The useMutation result now exposes a method which can be reset.

Bug Fixes (due to @brainkim in #8596):

  • The useQuery and useLazyQuery hooks will now have ObservableQuery methods defined consistently.
  • Calling useLazyQuery methods like startPolling will start the query.
  • Calling the useLazyQuery execution function will now behave more like refetch. previousData will be preserved.
  • standby fetchPolicies will now act like skip: true more consistently.
  • Calling refetch on a skipped query will have no effect (issue #8270).
  • Prevent onError and onCompleted functions from firing continuously, and improving their polling behavior.

3.4.0

28 Jul 17:40
550ec23
Compare
Choose a tag to compare

Apollo Client 3.4.0

New documentation

Improvements

  • InMemoryCache now guarantees that any two result objects returned by the cache (from readQuery, readFragment, etc.) will be referentially equal (===) if they are deeply equal. Previously, === equality was often achievable for results for the same query, on a best-effort basis. Now, equivalent result objects will be automatically shared among the result trees of completely different queries. This guarantee is important for taking full advantage of optimistic updates that correctly guess the final data, and for "pure" UI components that can skip re-rendering when their input data are unchanged.
    @benjamn in #7439

  • Mutations now accept an optional callback function called onQueryUpdated, which will be passed the ObservableQuery and Cache.DiffResult objects for any queries invalidated by cache writes performed by the mutation's final update function. Using onQueryUpdated, you can override the default FetchPolicy of the query, by (for example) calling ObservableQuery methods like refetch to force a network request. This automatic detection of invalidated queries provides an alternative to manually enumerating queries using the refetchQueries mutation option. Also, if you return a Promise from onQueryUpdated, the mutation will automatically await that Promise, rendering the awaitRefetchQueries option unnecessary.
    @benjamn in #7827

  • Support client.refetchQueries as an imperative way to refetch queries, without having to pass options.refetchQueries to client.mutate.
    @dannycochran in #7431

  • Improve standalone client.refetchQueries method to support automatic detection of queries needing to be refetched.
    @benjamn in #8000

  • Fix remaining barriers to loading @apollo/client/core as native ECMAScript modules from a CDN like esm.run. Importing @apollo/client from a CDN will become possible once we move all React-related dependencies into @apollo/client/react in Apollo Client 4.
    @benjamn in #8266

  • InMemoryCache supports a new method called batch, which is similar to performTransaction but takes named options rather than positional parameters. One of these named options is an onDirty(watch, diff) callback, which can be used to determine which watched queries were invalidated by the batch operation.
    @benjamn in #7819

  • Allow merge: true field policy to merge Reference objects with non-normalized objects, and vice-versa.
    @benjamn in #7778

  • Allow identical subscriptions to be deduplicated by default, like queries.
    @jkossis in #6910

  • Always use POST request when falling back to sending full query with @apollo/client/link/persisted-queries.
    @rieset in #7456

  • The FetchMoreQueryOptions type now takes two instead of three type parameters (<TVariables, TData>), thanks to using Partial<TVariables> instead of K extends typeof TVariables and Pick<TVariables, K>.
    @ArnaudBarre in #7476

  • Pass variables and context to a mutation's update function. Note: The type of the update function is now named MutationUpdaterFunction rather than MutationUpdaterFn, since the older type was broken beyond repair. If you are using MutationUpdaterFn in your own code, please use MutationUpdaterFunction instead.
    @jcreighton in #7902

  • A resultCacheMaxSize option may be passed to the InMemoryCache constructor to limit the number of result objects that will be retained in memory (to speed up repeated reads), and calling cache.reset() now releases all such memory.
    @SofianHn in #8701

  • Fully remove result cache entries from LRU dependency system when the corresponding entities are removed from InMemoryCache by eviction, or by any other means.
    @sofianhn and @benjamn in #8147

  • Expose missing field errors in results.
    @brainkim in #8262

  • Add expected/received variables to No more mocked responses... error messages generated by MockLink.
    @markneub in #8340

  • The InMemoryCache version of the cache.gc method now supports additional options for removing non-essential (recomputable) result caching data.
    @benjamn in #8421

  • Suppress noisy Missing cache result fields... warnings by default unless setLogVerbosity("debug") called.
    @benjamn in #8489

  • Improve interaction between React hooks and React Fast Refresh in development.
    @andreialecu in #7952

Potentially disruptive changes

  • To avoid retaining sensitive information from mutation root field arguments, Apollo Client v3.4 automatically clears any ROOT_MUTATION fields from the cache after each mutation finishes. If you need this information to remain in the cache, you can prevent the removal by passing the keepRootFields: true option to client.mutate. ROOT_MUTATION result data are also passed to the mutation update function, so we recommend obtaining the results that way, rather than using keepRootFields: true, if possible.
    @benjamn in #8280

  • Internally, Apollo Client now controls the execution of development-only code using the __DEV__ global variable, rather than process.env.NODE_ENV. While this change should not cause any visible differences in behavior, it will increase your minified+gzip bundle size by more than 3.5kB, unless you configure your minifier to replace __DEV__ with a true or false constant, the same way you already replace process.env.NODE_ENV with a string literal like "development" or "production". For an example of configuring a Create React App project without ejecting, see this pull request for our React Apollo reproduction template.
    @benjamn in #8347

  • Internally, Apollo Client now uses namespace syntax (e.g. import * as React from "react") for imports whose types are re-exported (and thus may appear in .d.ts files). This change should remove any need to configure esModuleInterop or allowSyntheticDefaultImports in tsconfig.json, but might require updating bundler configurations that specify named exports of the react and prop-types packages, to include exports like createContext and createElement (example).
    @devrelm in #7742

  • Respect no-cache fetch policy (by not reading any data from the cache) for loading: true results triggered by notifyOnNetworkStatusChange: true.
    @jcreighton in #7761

  • The TypeScript return types of the getLastResult and getLastError methods of ObservableQuery now correctly include the possibility of returning undefined. If you happen to be calling either of these methods directly, you may need to adjust how the calling code handles the methods' possibly-undefined results.
    @benjamn in #8394

  • Log non-fatal invariant.error message when fields are missing from result objects written into InMemoryCache, rather than throwing an exception. While this change relaxes an exception to be merely an error message, which is usually a backwards-compatible change, the error messages are logged in more cases now than the exception was previously thrown, and those new error messages may be worth investigating to discover potential problems in your application. The errors ...

Read more

3.3.0

24 Nov 21:57
0b66021
Compare
Choose a tag to compare

Apollo Client 3.3.0

Bug Fixes

  • Update @wry/equality to consider undefined properties equivalent to missing properties.
    @benjamn in #7108

  • Prevent memory leaks involving unused onBroadcast function closure created in ApolloClient constructor.
    @kamilkisiela in #7161

  • Provide default empty cache object for root IDs like ROOT_QUERY, to avoid differences in behavior before/after ROOT_QUERY data has been written into InMemoryCache.
    @benjamn in #7100

  • Cancel queryInfo.notifyTimeout in QueryInfo#markResult to prevent unnecessary network requests when using a FetchPolicy of cache-and-network or network-only in a React component with multiple useQuery calls.
    @benjamn in #7347

Potentially breaking changes

  • Ensure cache.readQuery and cache.readFragment always return TData | null, instead of throwing MissingFieldError exceptions when missing fields are encountered.
    @benjamn in #7098

    Since this change converts prior exceptions to null returns, and since null was already a possible return value according to the TData | null return type, we are confident this change will be backwards compatible (as long as null was properly handled before).

  • HttpLink will now automatically strip any unused variables before sending queries to the GraphQL server, since those queries are very likely to fail validation, according to the All Variables Used rule in the GraphQL specification. If you depend on the preservation of unused variables, you can restore the previous behavior by passing includeUnusedVariables: true to the HttpLink constructor (which is typically passed as options.link to the ApolloClient constructor).
    @benjamn in #7127

  • Ensure MockLink (used by MockedProvider) returns mock configuration errors (e.g. No more mocked responses for the query ...) through the Link's Observable, instead of throwing them. These errors are now available through the error property of a result.
    @hwillson in #7110

    Returning mock configuration errors through the Link's Observable was the default behavior in Apollo Client 2.x. We changed it for 3, but the change has been problematic for those looking to migrate from 2.x to 3. We've decided to change this back with the understanding that not many people want or are relying on MockLink's throwing exception approach. If you want to change this functionality, you can define custom error handling through MockLink.setOnError.

  • Unsubscribing the last observer from an ObservableQuery will once again unsubscribe from the underlying network Observable in all cases, as in Apollo Client 2.x, allowing network requests to be cancelled by unsubscribing.
    @javier-garcia-meteologica in #7165 and #7170.

  • The independent QueryBaseOptions and ModifiableWatchQueryOptions interface supertypes have been eliminated, and their fields are now defined by QueryOptions.
    @DCtheTall in #7136

  • Internally, Apollo Client now avoids nested imports from the graphql package, importing everything from the top-level package instead. For example,

    import { visit } from "graphql/language/visitor"

    is now just

    import { visit } from "graphql"

    Since the graphql package uses .mjs modules, your bundler may need to be configured to recognize .mjs files as ECMAScript modules rather than CommonJS modules.
    @benjamn in #7185

Improvements

  • Support inheritance of type and field policies, according to possibleTypes.
    @benjamn in #7065

  • Allow configuring custom merge functions, including the merge: true and merge: false shorthands, in type policies as well as field policies.
    @benjamn in #7070

  • The verbosity of Apollo Client console messages can be globally adjusted using the setLogVerbosity function:

    import { setLogVerbosity } from "@apollo/client";
    setLogVerbosity("log"); // display all messages
    setLogVerbosity("warn"); // display only warnings and errors (default)
    setLogVerbosity("error"); // display only errors
    setLogVerbosity("silent"); // hide all console messages

    Remember that all logs, warnings, and errors are hidden in production.
    @benjamn in #7226

  • Modifying InMemoryCache fields that have keyArgs configured will now invalidate only the field value with matching key arguments, rather than invalidating all field values that share the same field name. If keyArgs has not been configured, the cache must err on the side of invalidating by field name, as before.
    @benjamn in #7351

  • Shallow-merge options.variables when combining existing or default options with newly-provided options, so new variables do not completely overwrite existing variables.
    @amannn in #6927

  • Avoid displaying Cache data may be lost... warnings for scalar field values that happen to be objects, such as JSON data.
    @benjamn in #7075

  • In addition to the result.data property, useQuery and useLazyQuery will now provide a result.previousData property, which can be useful when a network request is pending and result.data is undefined, since result.previousData can be rendered instead of rendering an empty/loading state.
    @hwillson in #7082

  • Passing validate: true to the SchemaLink constructor will enable validation of incoming queries against the local schema before execution, returning validation errors in result.errors, just like a non-local GraphQL endpoint typically would.
    @amannn in #7094

  • Allow optional arguments in keyArgs: [...] arrays for InMemoryCache field policies.
    @benjamn in #7109

  • Avoid registering QueryPromise when skip is true during server-side rendering.
    @izumin5210 in #7310

  • ApolloCache objects (including InMemoryCache) may now be associated with or disassociated from individual reactive variables by calling reactiveVar.attachCache(cache) and/or reactiveVar.forgetCache(cache).
    @benjamn in #7350

3.2.0

14 Sep 18:51
062b76b
Compare
Choose a tag to compare

Apollo Client 3.2.0

Bug Fixes

  • Use options.nextFetchPolicy internally to restore original FetchPolicy after polling with fetchPolicy: "network-only", so that polling does not interfere with normal query watching.
    @benjamn in #6893

  • Initialize ObservableQuery in updateObservableQuery even if skip is true.
    @mu29 in #6999

  • Prevent full reobservation of queries affected by optimistic mutation updates, while still delivering results from the cache.
    @benjamn in #6854

Improvements

  • In TypeScript, all APIs that take DocumentNode parameters now may alternatively take TypeDocumentNode<Data, Variables>. This type has the same JavaScript representation but allows the APIs to infer the data and variable types instead of requiring you to specify types explicitly at the call site.
    @dotansimha in #6720

  • Bring back an improved form of heuristic fragment matching, by allowing possibleTypes to specify subtype regular expression strings, which count as matches if the written result object has all the fields expected for the fragment.
    @benjamn in #6901

  • Allow options.nextFetchPolicy to be a function that takes the current FetchPolicy and returns a new (or the same) FetchPolicy, making nextFetchPolicy more suitable for global use in defaultOptions.watchQuery.
    @benjamn in #6893

  • Implement useReactiveVar hook for consuming reactive variables in React components.
    @benjamn in #6867

  • Move apollo-link-persisted-queries implementation to @apollo/client/link/persisted-queries. Try running our automated imports transform to handle this conversion, if you're using apollo-link-persisted-queries.
    @hwillson in #6837

  • Disable feud-stopping logic after any cache.evict or cache.modify operation.
    @benjamn in
    #6817 and
    #6898

  • Throw if writeFragment cannot identify options.data when no options.id provided.
    @jcreighton in #6859

  • Provide options.storage object to cache.modify functions, as provided to read and merge functions.
    @benjamn in #6991

  • Allow cache.modify functions to return details.INVALIDATE (similar to details.DELETE) to invalidate the current field, causing affected queries to rerun, even if the field's value is unchanged.
    @benjamn in #6991

  • Support non-default ErrorPolicy values (that is, "ignore" and "all", in addition to the default value "none") for mutations and subscriptions, like we do for queries.
    @benjamn in #7003

  • Remove invariant forbidding a FetchPolicy of cache-only in ObservableQuery#refetch.
    @benjamn in ccb0a79a, fixing #6702

Apollo Client 3.1.5

Bug Fixes

  • Make ApolloQueryResult.data field non-optional again.
    @benjamn in #6997

Improvements

  • Allow querying Connection metadata without args in relayStylePagination.
    @anark in #6935

Apollo Client 3.1.4

Bug Fixes

  • Restrict root object identification to ROOT_QUERY (the ID corresponding to the root Query object), allowing Mutation and Subscription as user-defined types.
    @benjamn in #6914

  • Prevent crash when pageInfo and empty edges are received by relayStylePagination.
    @fracmak in #6918

Apollo Client 3.1.3

Bug Fixes

  • Consider only result.data (rather than all properties of result) when settling cache feuds.
    @danReynolds in #6777

Improvements

Apollo Client 3.1.2

Bug Fixes

Improvements

  • Allow SchemaLink.Options.context function to be async (or return a Promise).
    @benjamn in #6735

Apollo Client 3.1.1

Bug Fixes

  • Re-export cache types from @apollo/client/core (and thus also @apollo/client), again.
    @benjamn in #6725

3.1.0

28 Jul 16:17
824bbe7
Compare
Choose a tag to compare

Apollo Client 3.1.0

Bug Fixes

  • Rework interdependencies between @apollo/client/* entry points, so that CommonJS and ESM modules are supported equally well, without any duplication of shared code.
    @benjamn in #6656 and #6657

  • Tolerate !== callback functions (like onCompleted and onError) in useQuery options, since those functions are almost always freshly evaluated each time useQuery is called.
    @hwillson and @benjamn in #6588

  • Respect context.queryDeduplication if provided, and otherwise fall back to client.deduplication (as before).
    @igaloly in #6261 and @Kujawadl in #6526

  • Refactor ObservableQuery#getCurrentResult to reenable immediate delivery of warm cache results. As part of this refactoring, the ApolloCurrentQueryResult type was eliminated in favor of ApolloQueryResult.
    @benjamn in #6710

  • Avoid clobbering defaultOptions with undefined values.
    @benjamn in #6715

Improvements

  • Apollo Client will no longer modify options.fetchPolicy unless you pass options.nextFetchPolicy to request an explicit change in FetchPolicy after the current request. Although this is technically a breaking change, options.nextFieldPolicy makes it easy to restore the old behavior (by passing cache-first).
    @benjamn in #6712, reverting #6353

  • Errors of the form Invariant Violation: 42 thrown in production can now be looked up much more easily, by consulting the auto-generated @apollo/client/invariantErrorCodes.js file specific to your @apollo/client version.
    @benjamn in #6665

  • Make the client field of the MutationResult type non-optional, since it is always provided.
    @glasser in #6617

  • Allow passing an asynchronous options.renderFunction to getMarkupFromTree.
    @richardscarrott in #6576

  • Ergonomic improvements for merge and keyArgs functions in cache field policies.
    @benjamn in #6714

Apollo Client 3.0.2

Bug Fixes

  • Avoid duplicating graphql/execution/execute dependency in CommonJS bundle for @apollo/client/link/schema, fixing instanceof errors reported in #6621 and #6614.
    @benjamn in #6624

Apollo Client 3.0.1

Bug Fixes

  • Make sure useQuery onCompleted is not fired when skip is true.
    @hwillson in #6589

  • Revert changes to peerDependencies in package.json (#6594), which would have allowed using incompatible future versions of graphql and/or react due to overly-permissive >= version constraints.
    @hwillson in #6605

3.0.0

14 Jul 16:15
5130409
Compare
Choose a tag to compare

Apollo Client 3.0.0

Improvements

⚠️ Note: As of 3.0.0, Apollo Client uses a new package name: @apollo/client

ApolloClient

  • [BREAKING] ApolloClient is now only available as a named export. The default ApolloClient export has been removed.
    @hwillson in #5425

  • [BREAKING] The queryManager property of ApolloClient instances is now marked as private, paving the way for a more aggressive redesign of its API.

  • [BREAKING] Apollo Client will no longer deliver "stale" results to ObservableQuery consumers, but will instead log more helpful errors about which cache fields were missing.
    @benjamn in #6058

  • [BREAKING] ApolloError's thrown by Apollo Client no longer prefix error messages with GraphQL error: or Network error:. To differentiate between GraphQL/network errors, refer to ApolloError's public graphQLErrors and networkError properties.
    @lorensr in #3892

  • [BREAKING] Support for the @live directive has been removed, but might be restored in the future if a more thorough implementation is proposed.
    @benjamn in #6221

  • [BREAKING] Apollo Client 2.x allowed @client fields to be passed into the link chain if resolvers were not set in the constructor. This allowed @client fields to be passed into Links like apollo-link-state. Apollo Client 3 enforces that @client fields are local only, meaning they are no longer passed into the link chain, under any circumstances.
    @hwillson in #5982

  • [BREAKING?] Refactor QueryManager to make better use of observables and enforce fetchPolicy more reliably.
    @benjamn in #6221

  • The updateQuery function previously required by fetchMore has been deprecated with a warning, and will be removed in the next major version of Apollo Client. Please consider using a merge function to handle incoming data instead of relying on updateQuery.
    @benjamn in #6464

  • Helper functions for generating common pagination-related field policies may be imported from @apollo/client/utilities. The most basic helper is concatPagination, which emulates the concatenation behavior of typical updateQuery functions. A more sophisticated helper is offsetLimitPagination, which implements offset/limit-based pagination. If you are consuming paginated data from a Relay-friendly API, use relayStylePagination. Feel free to use these helper functions as inspiration for your own field policies, and/or modify them to suit your needs.
    @benjamn in #6465

  • Updated to work with graphql@15.
    @durchanek in #6194 and #6279
    @hagmic in #6328

  • Apollo Link core and HTTP related functionality has been merged into @apollo/client. Functionality that was previously available through the apollo-link, apollo-link-http-common and apollo-link-http packages is now directly available from @apollo/client (e.g. import { HttpLink } from '@apollo/client'). The ApolloClient constructor has also been updated to accept new uri, headers and credentials options. If uri is specified, Apollo Client will take care of creating the necessary HttpLink behind the scenes.
    @hwillson in #5412

  • The gql template tag should now be imported from the @apollo/client package, rather than the graphql-tag package. Although the graphql-tag package still works for now, future versions of @apollo/client may change the implementation details of gql without a major version bump.
    @hwillson in #5451

  • @apollo/client/core can be used to import the Apollo Client core, which includes everything the main @apollo/client package does, except for all React related functionality.
    @kamilkisiela in #5541

  • Several deprecated methods have been fully removed:

    • ApolloClient#initQueryManager
    • QueryManager#startQuery
    • ObservableQuery#currentResult
  • Apollo Client now supports setting a new ApolloLink (or link chain) after new ApolloClient() has been called, using the ApolloClient#setLink method.
    @hwillson in #6193

  • The final time a mutation update function is called, it can no longer accidentally read optimistic data from other concurrent mutations, which ensures the use of optimistic updates has no lasting impact on the state of the cache after mutations have finished.
    @benjamn in #6551

  • Apollo links that were previously maintained in https://github.com/apollographql/apollo-link have been merged into the Apollo Client project. They should be accessed using the new entry points listed in the migration guide.
    @hwillson in #

InMemoryCache

⚠️ Note: InMemoryCache has been significantly redesigned and rewritten in Apollo Client 3.0. Please consult the migration guide and read the new documentation to understand everything that has been improved.

  • The InMemoryCache constructor should now be imported directly from @apollo/client, rather than from a separate package. The apollo-cache-inmemory package is no longer supported.

    The @apollo/client/cache entry point can be used to import InMemoryCache without importing other parts of the Apollo Client codebase.
    @hwillson in #5577

  • [BREAKING] FragmentMatcher, HeuristicFragmentMatcher, and IntrospectionFragmentMatcher have all been removed. We now recommend using InMemoryCache’s possibleTypes option instead. For more information see the Defining possibleTypes manually section of the docs.
    @benjamn in #5073

  • [BREAKING] As promised in the Apollo Client 2.6 blog post, all cache results are now frozen/immutable.
    @benjamn in #5153

  • [BREAKING] Eliminate "generated" cache IDs to avoid normalizing objects with no meaningful ID, significantly reducing cache memory usage. This might be a backwards-incompatible change if your code depends on the precise internal representation of normalized data in the cache.
    @benjamn in #5146

  • [BREAKING] InMemoryCache will no longer merge the fields of written objects unless the objects are known to have the same identity, and the values of fields with the same name will not be recursively merged unless a custom merge function is defined by a field policy for that field, within a type policy associated with the __typename of the parent object.
    @benjamn in #5603

  • [BREAKING] InMemoryCache now throws when data with missing or undefined query fields is written into the cache, rather than just warning in development.
    @benjamn in #6055

  • [BREAKING] client|cache.writeData have been fully removed. writeData usage is one of the easiest ways to turn faulty assumptions about how the cache represents data internally, into cache inconsistency and corruption. client|cache.writeQuery, client|cache.writeFragment, and/or cache.modify can be used to update the cache.
    @benjamn in #5923

  • InMemoryCache now supports tracing garbage collection and eviction. Note that the signature of the evict method has been simplified in a potentially backwards-incompatible way.
    @benjamn in #5310

  • [beta-BREAKING] Please note that the cache.evict method now requires Cache.EvictOptions, though it pr...

Read more

v3.0.0-rc.0

02 Jun 16:11
25c24b8
Compare
Choose a tag to compare
v3.0.0-rc.0 Pre-release
Pre-release

Now that the release candidate phase of testing has begun, we will do our very best to avoid introducing any new features or breaking API changes, unless those changes are absolutely necessary to fix bugs.

We are very much aware of a number of outstanding bugs, and we fully intend to fix all known bugs before the final AC3 release, in addition to continuing to write and edit the documentation for new AC3 features: https://github.com/apollographql/apollo-client/milestone/14

If you have been waiting for a signal that the AC3 API is stable/frozen, this is it. However, if you are not interested in helping to identify and fix (or at least work around) the remaining issues, then you should wait for the final release before updating.

Changes: https://github.com/apollographql/apollo-client/blob/v3.0.0-rc.0/CHANGELOG.md

2.6.8

14 Dec 12:06
Compare
Choose a tag to compare

Apollo Client 2.6.8

Apollo Client (2.6.8)

GraphQL Anywhere (4.2.6)

Apollo Boost (0.4.7)

  • Replace GlobalFetch reference with WindowOrWorkerGlobalScope.
    @abdonrd in #5373

  • Add assumeImmutableResults typing to apollo boost PresetConfig interface.
    @bencoullie in #5571