Skip to content

Releases: TanStack/query

v2.0.0-next.5

19 Jun 16:58
591dabd
Compare
Choose a tag to compare
v2.0.0-next.5 Pre-release
Pre-release

2.0.0-next.5 (2020-06-19)

Bug Fixes

  • makeQueryCache config was not optional in the type def (#592) (591dabd)

v1.5.9

19 Jun 20:46
1fc7ed0
Compare
Choose a tag to compare

1.5.9 (2020-06-19)

Bug Fixes

  • types: add mutateOptions on MutationFunction (#594) (1fc7ed0)

v2.0.0-next.4

18 Jun 22:49
Compare
Choose a tag to compare
v2.0.0-next.4 Pre-release
Pre-release

2.0.0-next.4 (2020-06-18)

Bug Fixes

  • different refetchIntervals per instance use the min (b9168b8)

v2.0.0-next.3

18 Jun 07:46
Compare
Choose a tag to compare
v2.0.0-next.3 Pre-release
Pre-release

2.0.0-next.3 (2020-06-18)

Bug Fixes

  • tests: fix prefechQuery test (2134f49)
  • prefetchQuery back to normal, setQueryData more strict, updated docs (26844a9)

v2.0.0-next.2

17 Jun 18:34
Compare
Choose a tag to compare
v2.0.0-next.2 Pre-release
Pre-release

2.0.0-next.2 (2020-06-17)

Bug Fixes

  • status booleans for useMutation (8f00a71)

v2.0.0-next.1

17 Jun 02:20
Compare
Choose a tag to compare
v2.0.0-next.1 Pre-release
Pre-release

New Features

  • The booleans isSuccess, isError isLoading and a new one called isIdle have been added to the queryInfo object returned by useQuery and friends. These are derived safely from the queryInfo.status and are guaranteed to not overlap. In most situations, they are easier to use, less typo-prone than status strings and also more terse for determining what to render based on the status of a query.
  • queryCaches is now exported, which allows you to clean up all query caches that were created. We do this in our own tests when multiple caches are used for testing and to be thorough.
  • fetchMore now supports an optional previous option, which will determine if the data you are fetching is should be prepended instead of appended to your infinite list. eg, fetchMore(nextPageVars, { previous: true })
  • makeQueryCache now accepts an optional configuration object. The defaultConfig object is used to override the default query configuration config to use inside of this cache. The frozen option if set to true will simulate React Query being run on the server, where no queries are cached for privacy and safety concerns. This is the default when using React Query on the server and is optional. You can also set it to true on the server and have it work as it would on the client. More information on this coming soon!
  • refetchInterval can now be changed on the fly. Check out the auto-refetching example to see it in action!

Breaking Changes

  • Conditional, falsy or nullish query keys have been replaced by the enabled config flag. This flag must be a boolean-esque value, not a function. If you are looking to replace the throwable function option, you should instead use optional chaining, eg. useQuery(user?.id, fn, { enabled: user?.id }).
  • Dependent Queries (via the enabled option) will now start in a new idle state if they are initialized with no data and enabled: false.
  • refetchQueries has been replace by invalidateQueries. Previously, refetchQueries would refetch any query key it matched that was stale, even if it was not currently being used on the screen. This has changed and it will now only refetch active queries (those being subscribed to with useQuery and friends). All other queries that it matches will simply be marked as "stale" and be refetched when they are rendered next, if ever. You can also pass an invalidateQueries(queryKey, { refetchActive: false }) option if you do not want active queries to refetch either. This should save some bandwidth for queries that were cached, but not in use that will no longer be fetched again until they are needed.
  • Config is now split into 3 parts, shared, queries and mutations
const globalConfig = {
  shared: {
    suspense,
    queryKeySerializerFn,
  },
  queries: {
    ...shared,
    enabled,
    retry,
    retryDelay,
    staleTime,
    cacheTime,
    refetchOnWindowFocus,
    refetchInterval,
    queryFnParamsFilter,
    refetchOnMount,
    isDataEqual,
    onError,
    onSuccess,
    onSettled,
    throwOnError,
    useErrorBoundary,
  },
  mutations: {
    ...shared,
    throwOnError,
    onMutate,
    onError,
    onSuccess,
    onSettled,
    useErrorBoundary,
  },
}
  • All force options have been removed. Functions that are meant to update the query always will. If you need to check that a query is stale before calling one of these functions, you can use queryCache.get(queryKey).state.isStale to do so.
  • Optional queryVariables have been removed. These didn't make much sense to begin with, and if you still need them, you can just inline them in your query function anyway, eg. useQuery(['hello', 'world'], (a, b) => queryFn(a, b, customVariable1, customVariable2))
  • As a migration tool, falsy and functional query keys will throw an error now, showing you where you need to convert to use the enabled config option
  • globalConfig.refetchAllOnWindowFocus, which previous overlapped in fuctionality with the query-level refetchOnWindowFocus has been consolidated to a single refetchOnWindowFocus that can set in the the global config.queries.refetchOnWindowFocus and also on a per query basis.
  • The refetch function returned by useQuery and friends will now always trigger a refetch for the query, regardless if the query is stale or not. This is way more clear and reliable to deal with.
  • prefetchQuery will no longer disable the next render of that query using useQuery (and friends). Instead, the staleTime will be respected for the prefetchQuery call, so if prefetchQuery(key, fn, { staletime: 5000 }) is called, and then useQuery(key, fn, { staleTime: 1000 }) is rendered within those initial 5000 milliseconds, the query will not refetch in the background. But if the stale time has been reached by the time useQuery renders, it will refetch in the background.
  • prefetchQuery's force option has been removed. When you call prefetchQuery, the queryFn will always be called, regardless if the query is stale or not.
  • prefetchQuery's throwOnError option is now located in a fourth argument, after the query config, eg. prefetchQuery(key, fn, config, { throwOnError: true })

v1.5.8

15 Jun 01:18
06feac8
Compare
Choose a tag to compare

1.5.8 (2020-06-15)

Bug Fixes

  • types: change return type of removeQueries (#582) (21b9b01)
  • types: enable more types for first QueryKey (#577) (87008db)
  • force patch release (b9690d4)

v1.5.7

08 Jun 19:01
cf9bd9c
Compare
Choose a tag to compare

1.5.7 (2020-06-08)

Bug Fixes

  • remove shouldContinueRetryOnFocus on success (#563) (cf9bd9c)

v1.5.6

08 Jun 14:45
94cdeb5
Compare
Choose a tag to compare

1.5.6 (2020-06-08)

Bug Fixes

  • types: adapt type definition of dataOrUpdater in setQueryData (#540) (b528564)
  • types: default TError type (#547) (4261a65)
  • types: ReactQueryConfigProvider error type (#560) (94cdeb5), closes #542

v1.5.5

02 Jun 04:48
Compare
Choose a tag to compare

1.5.5 (2020-06-02)

Bug Fixes

  • useMutation does not await non-promise (4f56c31), closes #504