-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQuery.rei
52 lines (45 loc) · 1.08 KB
/
Query.rei
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
open Revery.UI.React;
include (module type of S);
module type Query = {
type t('responseType) = 'responseType;
type status('responseType) =
| Idle
| Loading
| Error
| Data(t('responseType));
/** Returns the status of the query
{2 Example}
{[
let%hook status =
Graphql.useQuery(
~variables=HelloName.makeVariables(~name="Kim", ()),
HelloName.definition,
(),
);
/* somewhere further down your component */
let text =
switch (status) {
| Idle => "Idle"
| Data(query) => query#helloName
| Loading => "Loading..."
| Error => "Error"
};
]}
*/
let useQuery:
(
~variables: Yojson.Basic.t=?,
(Yojson.Basic.t => t('responseType), string, 'b),
unit,
Hooks.t(
(
Hooks.Reducer.t(status('responseType)),
Hooks.Effect.t(option(Yojson.Basic.t))
) =>
'c,
'd,
)
) =>
(status('responseType), Hooks.t('c, 'd));
};
module Make: (BC: BaseConfig) => Query;