V1 Migration
Fl-Query V1 comes with lot of breaking changes in the API. It is not possible to upgrade to V1 without making changes to your code if you were using anything below V1. This page will help you to migrate to V1.
Removal of APIs/methods/properties
keepPreviousData
has been removed from bothQuery
andInfiniteQuery
QueryClient
's (formerlyQueryBowl
)prefetchQuery
method was removeduse
QueryClient.fetchQuery
insteadsetQueryData
method was removeduse
QueryClient.getQuery().setData
insteadsetInfinityQueryData
method was removeduse
QueryClient.getInfinityQuery().setPageData
insteadresetQueries
method was removeduse
QueryClient.getQueries
and map over them to reset them insteadremoveQueries
method was removeduse
QueryClient.cache.removeQuery
insteadonQueriesUpdate
method was removeduse
QueryClient.getQuery().addListener
insteadonInfinityQueriesUpdate
method was removeduse
QueryClient.getInfinityQuery().addListener
insteadonMutationUpdate
method was removeduse
QueryClient.getMutation().addListener
insteadinvalidateQueries
method was removed
InfiniteQuery.initialPage
was removedThe unnecessary
getPreviousPageParam
is now removed fromInfiniteQuery
Renaming/Replacement of APIs/methods/properties
QueryBowl
was renamed toQueryClient
refetchQuery
=>refreshQuery
refetchQueries
=>refreshQueries
refetchInfiniteQuery
=>refreshInfiniteQuery
refetchInfiniteQueries
=>refreshInfiniteQueries
QueryBowlProvider
was renamed toQueryClientProvider
Query.refetch
was renamed toQuery.refresh
InfiniteQuery.refetchPages
has been replaced withInfiniteQuery.refresh
andInfiniteQuery.refreshAll
externalData
was renamed toargs
forQueryJob
,InfiniteQueryJob
andMutationJob
Now instead of passing callback,
Future.wait
is used withrefresh
to refetch a segment of pages.refreshAll
is a shorthand to refetch all pages at once.getNextPageParam
has been renamed tonextPage
Also,
fetchNextPage
has been renamed tofetchNext
Query
andInfiniteQuery
'ssetQueryData
has been renamed tosetData
and it now accepts data directly instead of a call back function
Refactored APIs/methods/properties
All the retry & cache invalidation related properties were moved to their own classes.
QueryBuilder
,InfiniteQueryBuilder
andMutationBuilder
doesn't accept jobs by default. To use the old Jobs API,.withJob
constructor must be used.- Similarly,
useQuery
,useInfiniteQuery
,useMutation
doesn't accept jobs now. UseuseQueryJob
,useInfiniteQueryJob
anduseMutationJob
instead. - Retry related properties were moved to
RetryConfig
classretries
was renamed tomaxRetries
- Cache invalidation related properties were moved to
RefreshConfig
classstaleTime
was renamed tostaleDuration
refetchInterval
was renamed torefreshInterval
refetchOnMount
was renamed torefreshOnMount