11# API Reference
22---
3- - [ ` ReactQuery.Provider.createClient() ` ] ( #reactqueryprovidercreateclient )
4- - [ ` ReactQuery.Provider.make() ` ] ( #reactqueryprovidermake )
3+ - [ ` Provider.createClient() ` ] ( #providercreateclient )
4+ - [ ` Provider.make() ` ] ( #providermake )
5+ - [ ` DevTools.make(...) ` ] ( #devtoolsmake )
6+ - [ ` useQueryClient ` ] ( #usequeryclient )
7+ - [ ` useQuery ` ] ( #usequery )
8+ - [ ` useMutation ` ] ( #usemutation )
59
610
7- ### ` ReactQuery. Provider.createClient()`
11+ ### ` Provider.createClient() `
812
913The function responsible to create the query client
1014
@@ -17,10 +21,10 @@ Definition:
1721```
1822Usage:
1923``` rescript
20- let client = ReactQuery. Provider.createClient()
24+ let client = Provider.createClient()
2125```
2226
23- ### ` ReactQuery. Provider.make()`
27+ ### ` Provider.make() `
2428
2529The React Context Provider responsible to hold all the react-query context
2630
@@ -30,7 +34,7 @@ Definition:
3034 module Provider = {
3135 let make: (
3236 ~client: queryClientValue,
33- ~contextSharing: bool,
37+ ~contextSharing: bool=? ,
3438 ~children: React.element
3539 ) => React.element
3640 }
@@ -39,5 +43,84 @@ Definition:
3943Usage:
4044
4145``` rescript
42- <ReactQuery.Provider client={client}>children</ReactQuery.Provider>
46+ <Provider client={client}>children</Provider>
47+ ```
48+
49+ ### ` DevTools.make(...) `
50+
51+ The React Query DevTools Provider, which is responsible to initialize the React Query devtools
52+
53+ Definition:
54+
55+ ``` rescript
56+ module DevTools = {
57+ let make: (~initialIsOpen: bool=?) => React.element
58+ }
59+ ```
60+
61+ Usage:
62+
63+ ``` rescript
64+ <DevTools initialIsOpen={true} />
65+ ```
66+
67+ ### ` useQueryClient() `
68+
69+ The queryClient fetched from a hook
70+
71+ Definition:
72+
73+ ``` rescript
74+ let useQueryClient: unit => queryClient<'queryKey, 'queryData, 'queryError, 'pageParams>
75+ ```
76+
77+ Usage:
78+
79+ ``` rescript
80+ let queryClient = useQueryClient()
81+ ```
82+
83+ ### ` useQuery `
84+
85+ The hook responsible to get loading, error, and data when fetching data from an api
86+
87+ Definition:
88+
89+ ``` rescript
90+ let useQuery: queryOptions<'queryKey, 'queryData, 'queryError, 'pageParam> => queryResult<
91+ 'queryError,
92+ 'queryData,
93+ >
94+ ```
95+
96+ Usage:
97+
98+ ``` rescript
99+ let queryResult = useQuery({
100+ queryKey: ["articles"],
101+ queryFn: () => fetchArticles()
102+ })
103+ ```
104+
105+
106+ ### ` useMutation `
107+
108+ Definition:
109+
110+ ``` rescript
111+ let useMutation: mutationOptions<
112+ 'mutationVariables,
113+ 'mutationData,
114+ 'mutationError,
115+ 'unknown,
116+ > => mutationResult<'mutationVariables, 'mutationData, 'mutationError, 'unknown>
117+ ```
118+
119+ Usage:
120+
121+ ``` rescript
122+ let mutationResult = useMutation({
123+ mutationKey: ["articles"],
124+ mutationFn: () => addArticle(article)
125+ })
43126```
0 commit comments