@@ -23,31 +23,32 @@ await queryClient.prefetchQuery('posts', fetchPosts)
23
23
24
24
Its available methods are:
25
25
26
- - [ ` queryClient.fetchQuery ` ] ( #queryclientfetchquery )
27
- - [ ` queryClient.fetchInfiniteQuery ` ] ( #queryclientfetchinfinitequery )
28
- - [ ` queryClient.prefetchQuery ` ] ( #queryclientprefetchquery )
29
- - [ ` queryClient.prefetchInfiniteQuery ` ] ( #queryclientprefetchinfinitequery )
30
- - [ ` queryClient.getQueryData ` ] ( #queryclientgetquerydata )
31
- - [ ` queryClient.getQueriesData ` ] ( #queryclientgetqueriesdata )
32
- - [ ` queryClient.setQueryData ` ] ( #queryclientsetquerydata )
33
- - [ ` queryClient.getQueryState ` ] ( #queryclientgetquerystate )
34
- - [ ` queryClient.setQueriesData ` ] ( #queryclientsetqueriesdata )
35
- - [ ` queryClient.invalidateQueries ` ] ( #queryclientinvalidatequeries )
36
- - [ ` queryClient.refetchQueries ` ] ( #queryclientrefetchqueries )
37
- - [ ` queryClient.cancelQueries ` ] ( #queryclientcancelqueries )
38
- - [ ` queryClient.removeQueries ` ] ( #queryclientremovequeries )
39
- - [ ` queryClient.resetQueries ` ] ( #queryclientresetqueries )
40
- - [ ` queryClient.isFetching ` ] ( #queryclientisfetching )
41
- - [ ` queryClient.isMutating ` ] ( #queryclientismutating )
42
- - [ ` queryClient.getDefaultOptions ` ] ( #queryclientgetdefaultoptions )
43
- - [ ` queryClient.setDefaultOptions ` ] ( #queryclientsetdefaultoptions )
44
- - [ ` queryClient.getQueryDefaults ` ] ( #queryclientgetquerydefaults )
45
- - [ ` queryClient.setQueryDefaults ` ] ( #queryclientsetquerydefaults )
46
- - [ ` queryClient.getMutationDefaults ` ] ( #queryclientgetmutationdefaults )
47
- - [ ` queryClient.setMutationDefaults ` ] ( #queryclientsetmutationdefaults )
48
- - [ ` queryClient.getQueryCache ` ] ( #queryclientgetquerycache )
49
- - [ ` queryClient.getMutationCache ` ] ( #queryclientgetmutationcache )
50
- - [ ` queryClient.clear ` ] ( #queryclientclear )
26
+ * [ ` QueryClient ` ] ( #queryclient )
27
+ * [ ` queryClient.fetchQuery ` ] ( #queryclientfetchquery )
28
+ * [ ` queryClient.fetchInfiniteQuery ` ] ( #queryclientfetchinfinitequery )
29
+ * [ ` queryClient.prefetchQuery ` ] ( #queryclientprefetchquery )
30
+ * [ ` queryClient.prefetchInfiniteQuery ` ] ( #queryclientprefetchinfinitequery )
31
+ * [ ` queryClient.getQueryData ` ] ( #queryclientgetquerydata )
32
+ * [ ` queryClient.getQueriesData ` ] ( #queryclientgetqueriesdata )
33
+ * [ ` queryClient.setQueryData ` ] ( #queryclientsetquerydata )
34
+ * [ ` queryClient.getQueryState ` ] ( #queryclientgetquerystate )
35
+ * [ ` queryClient.setQueriesData ` ] ( #queryclientsetqueriesdata )
36
+ * [ ` queryClient.invalidateQueries ` ] ( #queryclientinvalidatequeries )
37
+ * [ ` queryClient.refetchQueries ` ] ( #queryclientrefetchqueries )
38
+ * [ ` queryClient.cancelQueries ` ] ( #queryclientcancelqueries )
39
+ * [ ` queryClient.removeQueries ` ] ( #queryclientremovequeries )
40
+ * [ ` queryClient.resetQueries ` ] ( #queryclientresetqueries )
41
+ * [ ` queryClient.isFetching ` ] ( #queryclientisfetching )
42
+ * [ ` queryClient.isMutating ` ] ( #queryclientismutating )
43
+ * [ ` queryClient.getDefaultOptions ` ] ( #queryclientgetdefaultoptions )
44
+ * [ ` queryClient.setDefaultOptions ` ] ( #queryclientsetdefaultoptions )
45
+ * [ ` queryClient.getQueryDefaults ` ] ( #queryclientgetquerydefaults )
46
+ * [ ` queryClient.setQueryDefaults ` ] ( #queryclientsetquerydefaults )
47
+ * [ ` queryClient.getMutationDefaults ` ] ( #queryclientgetmutationdefaults )
48
+ * [ ` queryClient.setMutationDefaults ` ] ( #queryclientsetmutationdefaults )
49
+ * [ ` queryClient.getQueryCache ` ] ( #queryclientgetquerycache )
50
+ * [ ` queryClient.getMutationCache ` ] ( #queryclientgetmutationcache )
51
+ * [ ` queryClient.clear ` ] ( #queryclientclear )
51
52
52
53
** Options**
53
54
@@ -471,6 +472,9 @@ The `getQueryDefaults` method returns the default options which have been set fo
471
472
const defaultOptions = queryClient .getQueryDefaults (' posts' )
472
473
```
473
474
475
+ > Note that if several query defaults match the given query key, the ** first** matching one is returned.
476
+ > This could lead to unexpected behaviours. See [ ` setquerydefaults ` ] ( #queryclientsetquerydefaults ) .
477
+
474
478
## ` queryClient.setQueryDefaults `
475
479
476
480
` setQueryDefaults ` can be used to set default options for specific queries:
@@ -488,6 +492,9 @@ function Component() {
488
492
- ` queryKey: QueryKey ` : [ Query Keys] ( ../guides/query-keys )
489
493
- ` options: QueryOptions `
490
494
495
+ > As stated in [ ` getquerydefaults ` ] ( #queryclientgetquerydefaults ) , the order of registration of query defaults does matter.
496
+ > Since the ** first** matching defaults are returned by ` getquerydefaults ` , the registration should be made in the following order: from the ** least generic key** to the ** most generic one** . This way, in case of specific key, the first matching one would be the expected one.
497
+
491
498
## ` queryClient.getMutationDefaults `
492
499
493
500
The ` getMutationDefaults ` method returns the default options which have been set for specific mutations:
0 commit comments