Skip to content

Releases: apollographql/apollo-client

v3.6.5

23 May 22:28
b86c363
Compare
Choose a tag to compare

Bug Fixes (from CHANGELOG.md)

  • Restore pre-v3.6 variables replacement behavior of ObservableQuery#reobserve method, fixing a regression that prevented removal of variables.
    @benjamn in #9741

  • Preserve previousData even when different query or client provided to useQuery, instead of resetting previousData to undefined in those cases, matching behavior prior to v3.6.0.
    @benjamn in #9734

  • Fix bug where onCompleted() and onError() are stale for useMutation().
    @charle692 in #9740

  • Limit scope of DeepMerger object reuse, and avoid using Object.isFrozen, which can introduce differences between development and production if objects that were frozen using Object.freeze in development are left unfrozen in production.
    @benjamn in #9742

  • Properly merge variables from original useLazyQuery(query, { variables }) with variables passed to execution function.
    @benjamn in #9758

What's Changed (auto-generated by GitHub)

  • Preserve previousData even when different client or query passed to useQuery by @benjamn in #9734
  • Restore pre-v3.6 variables replacement behavior of ObservableQuery#reobserve method by @benjamn in #9741
  • Clarify modifying response data in link docs by @hatched-kade in #9430
  • adds documentation on file uploads by @jpvajda in #9744
  • Fix improper syntax with spread operator by @mongodben in #9441
  • Reduce confusion about the query component by @jpvajda in #9747
  • Fix bug where onCompleted and onError are stale for useMutation. onCompleted and onError could not be changed while a mutation is executing. by @charle692 in #9740
  • Restrict DeepMerger mutable object reuse to fix subtle production-only bug by @benjamn in #9742
  • Merge variables from original useLazyQuery(query, { variables }) with variables passed to execution function by @benjamn in #9758

New Contributors

Full Changelog: v3.6.4...v3.6.5

v3.6.4

16 May 23:08
a46240f
Compare
Choose a tag to compare

Bug Fixes (from CHANGELOG.md)

  • Guarantee Concast cleanup without Observable cancelled prematurely rejection, potentially solving long-standing issues involving that error.
    @benjamn in #9701

  • Ensure useSubscription subscriptions are properly restarted after unmounting/remounting by React 18 in <StrictMode>.
    @kazekyo in #9707

Improvements (from CHANGELOG.md)

  • Internalize useSyncExternalStore shim, for more control than use-sync-external-store provides, fixing some React Native issues.
    @benjamn in #9675 and #9709

  • Provide @apollo/client/**/*.cjs.native.js versions of every @apollo/client/**/*.cjs bundle (including dependencies ts-invariant and zen-observable-ts) to help React Native's Metro bundler automatically resolve CommonJS entry point modules. These changes should render unnecessary the advice we gave in the v3.5.4 section below about metro.config.js.
    @benjamn in #9716

  • Handle falsy incoming data more gracefully in offetLimitPagination().merge function.
    @shobhitsharma in #9705

What's Changed (auto-generated by GitHub)

New Contributors

Full Changelog: v3.6.3...v3.6.4

v3.6.3

16 May 23:05
265abe2
Compare
Choose a tag to compare

Bug Fixes (from CHANGELOG.md)

  • Simplify useQuery(query, { defaultOptions }) default options processing in order to fix bug where skip: true queries failed to execute upon switching to skip: false.
    @benjamn in #9665

  • Add tests of skipping/unskipping and useLazyQuery with defaultOptions, and fix a bug causing duplicate requests.
    @benjamn in #9666

  • Update ts-invariant to version 0.10.2 to fix source map warnings.
    @benjamn in #9672

  • Test that useQuery queries with skip: true do not stall server-side rendering.
    @nathanmarks and @benjamn in #9677

  • Prevent useLazyQuery from making duplicate requests when its execution function is first called, and stop rejecting the Promise it returns when result.error is defined.
    @benjamn in #9684

  • Fix issue with useQuery returning loading: true state during server-side rendering with skip: true.
    @nathanmarks in #9679

What's Changed (auto-generated by GitHub)

  • Drastically simplify useQuery default options processing by @benjamn in #9665
  • Docs: fix typo in subscriptions.mdx by @pobch in #9663
  • Update ts-invariant to version 0.10.2 to fix source map warnings by @benjamn in #9672
  • Update queries.mdx by @anilpai in #5466
  • Fix failing regression test for skipped SSR useQuery stuck in standby by @benjamn in #9677
  • Add a comment about a new use of the content-type header by @glasser in #9683
  • Add missing assumeImmutableResults documentation by @henryqdineen in #9680
  • Prevent useLazyQuery from making duplicate requests when execution function first called by @benjamn in #9684
  • Fix issue with useQuery returning loading: true state during server-side rendering with skip: true by @nathanmarks in #9679
  • Add description & example of how to handle multiple parameters in read() when declaring typePolicies. by @Moristotle in #6755
  • Add link to ts-transform-graphql-tag in the performance docs by @hcharley in #5608

New Contributors

Full Changelog: v3.6.2...v3.6.3

3.6.2

03 May 00:16
1edccee
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v3.6.1...v3.6.2

v3.6.1

28 Apr 21:31
8389767
Compare
Choose a tag to compare

What's Changed

  • Remove WatchQueryOptions["fetchBlockingPromise"] option due to regressions by @benjamn in #9636
  • chore(deps): update dependency graphql-ws to v5.8.1 by @renovate in #9592
  • Update Full-stack tutorial links to point to Odyssey by @rkoron007 in #9610
  • changes the way the parser filters the array of definitions by @rasulomaroff in #9622
  • chore: updates roadmap by @jpvajda in #9628

New Contributors

Full Changelog: v3.6.0...v3.6.1

3.6.0

26 Apr 21:06
04a35d5
Compare
Choose a tag to compare

Note: for the most up-to-date version of this information, see CHANGELOG.md

Apollo Client 3.6.0 (2022-04-26)

Potentially disruptive changes

  • Calling fetchMore for queries using the cache-and-network or network-only fetch policies will no longer trigger additional network requests when cache results are complete. Instead, those complete cache results will be delivered as if using the cache-first fetch policy.
    @benjamn in #9504

  • Reimplement useQuery and useLazyQuery to use the proposed useSyncExternalStore API from React 18.
    @brainkim and @benjamn in #8785 and #9596

  • Fixed bug where the useLazyQuery execution function would always use the refetch method of ObservableQuery, instead of properly reapplying the current fetchPolicy using the reobserve method.
    @benjamn in #9564

    Since this reobserve method is useful and used internally, we have now exposed it as use[Lazy]Query(...).reobserve (which optionally takes a Partial<WatchQueryOptions> of new options), to supplement the existing refetch method. Note that reobserve permanently updates the variables and other options of the ObservableQuery, unlike refetch({ ...variables }), which does not save those variables.

  • The internal use of options.fetchBlockingPromise by useQuery and useLazyQuery may slightly delay the delivery of network results, compared to previous versions of Apollo Client. Since network results are already delivered asynchronously, these timing differences should not be disruptive in most cases. Nevertheless, please open an issue if the timing differences cause problems for your applications.
    @benjamn in #9599

React 18

In both its peerDependencies and its internal implementation, Apollo Client v3.6 should no longer prevent you from updating to React 18 in your applications.

Internally, we have refactored useQuery and useLazyQuery to be implemented in terms of React's new (shimmable) useSyncExternalStore hook, demonstrating Apollo Client can serve as an external store with a referentially stable, synchronous API, as needed by React.

As part of this refactoring, we also improved the behavior of useQuery and useLazyQuery when used in <React.StrictMode>, which double-renders components in development. While this double-rendering always results in calling useQuery twice, forcing Apollo Client to create and then discard an unnecessary ObservableQuery object, we now have multiple defenses in place against executing any network queries for the unused ObservableQuery objects.

In upcoming v3.6.x and v3.7 (beta) releases, we will be completely overhauling our server-side rendering utilities (getDataFromTree et al.), and introducing suspenseful versions of our hooks, to take full advantage of the new patterns React 18+ enables for data management libraries like Apollo Client.

Improvements

  • Allow BatchLink to cancel queued and in-flight operations.
    @PowerKiKi and @benjamn in #9248

  • Add GraphQLWsLink in @apollo/client/link/subscriptions. This link is similar to the existing WebSocketLink in @apollo/client/link/ws, but uses the newer graphql-ws package and protocol instead of the older subscriptions-transport-ws implementation. This functionality was technically first released in @apollo/client@3.5.10, but semantically belongs in the 3.6.0 minor version.
    @glasser in #9369

  • Allow passing defaultOptions to useQuery to avoid clobbering/resetting existing options when useQuery is called repeatedly.
    @benjamn in #9563, superseding #9223

  • Provide additional context to nextFetchPolicy functions to assist with fetchPolicy transitions. More details can be found in the nextFetchPolicy documentation.
    @benjamn in #9222

  • Remove nagging deprecation warning about passing an options.updateQuery function to fetchMore.
    @benjamn in #9504

  • Let addTypenameToDocument take any ASTNode (including DocumentNode, as before).
    @benjamn in #9595

  • Set useMutation internal isMounted variable to true again when component remounted.
    @devpeerapong in #9561

New Contributors

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