rescript-relay 1.1.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/package.json +5 -5
  3. package/postinstall.js +4 -0
  4. package/ppx-linux +0 -0
  5. package/ppx-macos-arm64 +0 -0
  6. package/ppx-macos-latest +0 -0
  7. package/ppx-windows-latest +0 -0
  8. package/relay-compiler-linux-musl/relay +0 -0
  9. package/relay-compiler-linux-x64/relay +0 -0
  10. package/relay-compiler-macos-arm64/relay +0 -0
  11. package/relay-compiler-macos-x64/relay +0 -0
  12. package/relay-compiler-win-x64/relay.exe +0 -0
  13. package/src/ReactExperimental.bs.js +4 -2
  14. package/src/ReactExperimental.res +1 -1
  15. package/src/ReactExperimental.resi +1 -1
  16. package/src/RescriptRelay.bs.js +13 -13
  17. package/src/RescriptRelay.res +3 -1
  18. package/src/RescriptRelay.resi +7 -2
  19. package/src/RescriptRelayUtils.bs.js +3 -3
  20. package/src/RescriptRelay_Fragment.bs.js +117 -0
  21. package/src/RescriptRelay_Fragment.res +239 -0
  22. package/src/RescriptRelay_Fragment.resi +86 -0
  23. package/src/RescriptRelay_Internal.bs.js +1 -1
  24. package/src/RescriptRelay_Mutation.bs.js +54 -0
  25. package/src/RescriptRelay_Mutation.res +146 -0
  26. package/src/RescriptRelay_Mutation.resi +54 -0
  27. package/src/RescriptRelay_Query.bs.js +87 -0
  28. package/src/RescriptRelay_Query.res +188 -0
  29. package/src/RescriptRelay_Query.resi +70 -0
  30. package/src/RescriptRelay_RelayResolvers.bs.js +14 -0
  31. package/src/RescriptRelay_RelayResolvers.res +21 -0
  32. package/src/RescriptRelay_RelayResolvers.resi +10 -0
  33. package/src/RescriptRelay_Subscriptions.bs.js +23 -0
  34. package/src/RescriptRelay_Subscriptions.res +51 -0
  35. package/src/RescriptRelay_Subscriptions.resi +15 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # master
2
2
 
3
+ # 1.2.1
4
+
5
+ ## Bug fix
6
+
7
+ - Proper import for `useBlockingPagination`. https://github.com/zth/rescript-relay/pull/459
8
+
9
+ # 1.2.0
10
+
11
+ This release mainly makes preparations under the hood for the upcoming `2.0` (ReScript v11 + uncurried mode support) and `3.0` (lots of changes, full uncurried mode only).
12
+
13
+ ## Breaking changes
14
+
15
+ - A trailing unit `()` arg is no longer needed in `Query.usePreloaded()`. What was previously `Query.usePreloaded(~queryRef, ())` is now just `Query.usePreloaded(~queryRef)`.
16
+
17
+ ## Improvements
18
+
19
+ - Add `@live` annotations to generated JSXv4 dynamic import compat modules, so they don't show up in dead code analysis (which they shouldn't).
20
+ - Preparations under the hood for ReScript v11 + uncurried mode.
21
+
22
+ # 1.1.1
23
+
24
+ - Fix M1 binary to include new JSXv4 dynamic import compat changes.
25
+
3
26
  # 1.1.0
4
27
 
5
28
  Notable changes:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rescript-relay",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "main": "src/RescriptRelay.res",
5
5
  "license": "MIT",
6
6
  "author": "Gabriel Nordeborn",
@@ -39,11 +39,10 @@
39
39
  "test:ci": "jest --ci --runInBand"
40
40
  },
41
41
  "devDependencies": {
42
- "rescript": "^10.1.3",
43
- "@rescript/react": "0.11.0",
42
+ "@glennsl/rescript-fetch": "^0.2.0",
43
+ "@rescript/react": "0.12.0-alpha.2",
44
44
  "@testing-library/jest-dom": "^5.16.3",
45
45
  "@testing-library/react": "^13.0.0-alpha.6",
46
- "bs-fetch": "^0.5.0",
47
46
  "graphql-query-test-mock": "^0.12.1",
48
47
  "jest": "^27.2.4",
49
48
  "nock": "^11.7.0",
@@ -51,7 +50,8 @@
51
50
  "react": "18.2.0",
52
51
  "react-dom": "18.2.0",
53
52
  "react-relay": "15.0.0",
54
- "relay-runtime": "15.0.0"
53
+ "relay-runtime": "15.0.0",
54
+ "rescript": "^11.0.0-beta.1"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@rescript/react": "*",
package/postinstall.js CHANGED
@@ -152,6 +152,10 @@ function removeInitialBinaries() {
152
152
  recursive: true,
153
153
  force: true,
154
154
  });
155
+ fs.rmSync(path.join(__dirname, "relay-compiler-win-x64"), {
156
+ recursive: true,
157
+ force: true,
158
+ });
155
159
  }
156
160
 
157
161
  switch (platform) {
package/ppx-linux CHANGED
Binary file
package/ppx-macos-arm64 CHANGED
Binary file
package/ppx-macos-latest CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -8,8 +8,10 @@ function useTransition(param) {
8
8
  var startTransition = match[1];
9
9
  return [
10
10
  match[0],
11
- React.useCallback((function (cb) {
12
- startTransition(cb, undefined);
11
+ React.useMemo((function (param) {
12
+ return function (cb) {
13
+ return startTransition(cb, undefined);
14
+ };
13
15
  }), [startTransition])
14
16
  ];
15
17
  }
@@ -9,7 +9,7 @@ external useTransitionWithOptions: unit => (
9
9
 
10
10
  let useTransition = () => {
11
11
  let (isPending, startTransition) = useTransitionWithOptions()
12
- (isPending, React.useCallback1(cb => startTransition(. cb, None), [startTransition]))
12
+ (isPending, React.useMemo1(() => cb => startTransition(. cb, None), [startTransition]))
13
13
  }
14
14
 
15
15
  module SuspenseList = {
@@ -7,7 +7,7 @@ external useTransitionWithOptions: unit => (
7
7
  (. unit => unit, option<{"name": option<string>}>) => unit,
8
8
  ) = "useTransition"
9
9
 
10
- let useTransition: unit => (bool, React.callback<unit => unit, unit>)
10
+ let useTransition: unit => (bool, (unit => unit) => unit)
11
11
 
12
12
  module SuspenseList: {
13
13
  @module("react") @react.component
@@ -50,22 +50,22 @@ function unwrapNormalizationArgument(wrapped) {
50
50
  var match = wrapped.kind;
51
51
  if (match === "Literal") {
52
52
  return {
53
- TAG: /* Literal */1,
53
+ TAG: "Literal",
54
54
  _0: wrapped
55
55
  };
56
56
  } else if (match === "ListValue") {
57
57
  return {
58
- TAG: /* ListValue */0,
58
+ TAG: "ListValue",
59
59
  _0: wrapped
60
60
  };
61
61
  } else if (match === "ObjectValue") {
62
62
  return {
63
- TAG: /* ObjectValue */2,
63
+ TAG: "ObjectValue",
64
64
  _0: wrapped
65
65
  };
66
66
  } else {
67
67
  return {
68
- TAG: /* Variable */3,
68
+ TAG: "Variable",
69
69
  _0: wrapped
70
70
  };
71
71
  }
@@ -196,13 +196,13 @@ function mapFetchPolicy(x) {
196
196
  return ;
197
197
  }
198
198
  switch (x) {
199
- case /* StoreOnly */0 :
199
+ case "StoreOnly" :
200
200
  return "store-only";
201
- case /* StoreOrNetwork */1 :
201
+ case "StoreOrNetwork" :
202
202
  return "store-or-network";
203
- case /* StoreAndNetwork */2 :
203
+ case "StoreAndNetwork" :
204
204
  return "store-and-network";
205
- case /* NetworkOnly */3 :
205
+ case "NetworkOnly" :
206
206
  return "network-only";
207
207
 
208
208
  }
@@ -210,10 +210,10 @@ function mapFetchPolicy(x) {
210
210
 
211
211
  function mapFetchQueryFetchPolicy(x) {
212
212
  if (x !== undefined) {
213
- if (x) {
214
- return "store-or-network";
215
- } else {
213
+ if (x === "NetworkOnly") {
216
214
  return "network-only";
215
+ } else {
216
+ return "store-or-network";
217
217
  }
218
218
  }
219
219
 
@@ -237,7 +237,7 @@ function MakeLoadQuery(C) {
237
237
  Caml_option.valFromOption(o).subscribe({
238
238
  complete: (function (param) {
239
239
  resolve({
240
- TAG: /* Ok */0,
240
+ TAG: "Ok",
241
241
  _0: undefined
242
242
  });
243
243
  })
@@ -245,7 +245,7 @@ function MakeLoadQuery(C) {
245
245
  return ;
246
246
  } else {
247
247
  return resolve({
248
- TAG: /* Error */1,
248
+ TAG: "Error",
249
249
  _0: undefined
250
250
  });
251
251
  }
@@ -507,6 +507,8 @@ module Observable = {
507
507
  external subscribe: (t<'response>, observer<'response>) => subscription = "subscribe"
508
508
 
509
509
  @send external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
510
+
511
+ external ignoreSubscription: subscription => unit = "%ignore"
510
512
  }
511
513
 
512
514
  module Network = {
@@ -593,7 +595,7 @@ module RequiredFieldLogger = {
593
595
 
594
596
  type t = (~kind: kind, ~owner: string, ~fieldPath: string) => unit
595
597
 
596
- let toJs: t => js = (f, arg) =>
598
+ let toJs: t => js = f => arg =>
597
599
  f(~kind=arg["kind"], ~owner=arg["owner"], ~fieldPath=arg["fieldPath"])
598
600
  }
599
601
 
@@ -615,6 +615,8 @@ module Observable: {
615
615
  /**Turns an `Observable` into a promise. _Beware_ that reading the response in the resulting promise is currently _not safe_ due to some internals of how ReScript Relay works. This will be resolved in the future.*/
616
616
  @send
617
617
  external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
618
+
619
+ /**Ignore this subscription.*/ external ignoreSubscription: subscription => unit = "%ignore"
618
620
  }
619
621
 
620
622
  /**Represents the network layer.*/
@@ -803,8 +805,11 @@ module Context: {
803
805
  /**The context provider you wrap your app in and pass your `Environment` for Relay to work.*/
804
806
  module Provider: {
805
807
  /**The React component you wrap your app in and pass your `Environment` for Relay to work.*/
806
- @react.component
807
- let make: (~environment: Environment.t, ~children: React.element) => React.element
808
+ type props<'environment, 'children> = {
809
+ environment: 'environment,
810
+ children: 'children,
811
+ }
812
+ let make: props<Environment.t, React.element> => React.element
808
813
  }
809
814
  }
810
815
 
@@ -61,11 +61,11 @@ function createAndAddEdgeToConnections(store, node, connections, edgeName, inser
61
61
  return ;
62
62
  }
63
63
  var edge = RelayRuntime.ConnectionHandler.createEdge(store, connection, node, edgeName);
64
- if (insertAt) {
65
- RelayRuntime.ConnectionHandler.insertEdgeBefore(connection, edge, undefined);
66
- } else {
64
+ if (insertAt === "Start") {
67
65
  RelayRuntime.ConnectionHandler.insertEdgeAfter(connection, edge, undefined);
66
+ return ;
68
67
  }
68
+ RelayRuntime.ConnectionHandler.insertEdgeBefore(connection, edge, undefined);
69
69
  }));
70
70
  }
71
71
 
@@ -0,0 +1,117 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var Curry = require("rescript/lib/js/curry.js");
5
+ var React = require("react");
6
+ var Caml_option = require("rescript/lib/js/caml_option.js");
7
+ var ReactRelay = require("react-relay");
8
+ var RescriptRelay = require("./RescriptRelay.bs.js");
9
+ var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
10
+ var UseBlockingPaginationFragment = require("react-relay/lib/relay-hooks/useBlockingPaginationFragment").default;
11
+
12
+ function useFragment(node, convertFragment, fRef) {
13
+ return RescriptRelay_Internal.internal_useConvertedValue(convertFragment, ReactRelay.useFragment(node, fRef));
14
+ }
15
+
16
+ function useFragmentOpt(fRef, node, convertFragment) {
17
+ var data = ReactRelay.useFragment(node, fRef);
18
+ return React.useMemo((function (param) {
19
+ if (!(data == null)) {
20
+ return Caml_option.some(Curry._1(convertFragment, data));
21
+ }
22
+
23
+ }), [(data == null) ? undefined : Caml_option.some(data)]);
24
+ }
25
+
26
+ function readInlineData(node, convertFragment, fRef) {
27
+ return Curry._1(convertFragment, ReactRelay.readInlineData(node, fRef));
28
+ }
29
+
30
+ function internal_makeRefetchableFnOpts(fetchPolicy, onComplete, param) {
31
+ return {
32
+ fetchPolicy: RescriptRelay.mapFetchPolicy(fetchPolicy),
33
+ onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
34
+ };
35
+ }
36
+
37
+ function usePaginationFragment(node, fRef, convertFragment, convertRefetchVariables) {
38
+ var p = ReactRelay.usePaginationFragment(node, fRef);
39
+ var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
40
+ return {
41
+ data: data,
42
+ loadNext: React.useMemo((function (param) {
43
+ return function (count, onComplete, param) {
44
+ return Curry._2(p.loadNext, count, {
45
+ onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
46
+ });
47
+ };
48
+ }), [p.loadNext]),
49
+ loadPrevious: React.useMemo((function (param) {
50
+ return function (count, onComplete, param) {
51
+ return Curry._2(p.loadPrevious, count, {
52
+ onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
53
+ });
54
+ };
55
+ }), [p.loadPrevious]),
56
+ hasNext: p.hasNext,
57
+ hasPrevious: p.hasPrevious,
58
+ isLoadingNext: p.isLoadingNext,
59
+ isLoadingPrevious: p.isLoadingPrevious,
60
+ refetch: React.useMemo((function (param) {
61
+ return function (variables, fetchPolicy, onComplete, param) {
62
+ return Curry._2(p.refetch, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(Curry._1(convertRefetchVariables, variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
63
+ };
64
+ }), [p.refetch])
65
+ };
66
+ }
67
+
68
+ function useBlockingPaginationFragment(node, fRef, convertFragment, convertRefetchVariables) {
69
+ var p = UseBlockingPaginationFragment(node, fRef);
70
+ var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
71
+ return {
72
+ data: data,
73
+ loadNext: React.useMemo((function (param) {
74
+ return function (count, onComplete, param) {
75
+ return Curry._2(p.loadNext, count, {
76
+ onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
77
+ });
78
+ };
79
+ }), [p.loadNext]),
80
+ loadPrevious: React.useMemo((function (param) {
81
+ return function (count, onComplete, param) {
82
+ return Curry._2(p.loadPrevious, count, {
83
+ onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
84
+ });
85
+ };
86
+ }), [p.loadPrevious]),
87
+ hasNext: p.hasNext,
88
+ hasPrevious: p.hasPrevious,
89
+ refetch: React.useMemo((function (param) {
90
+ return function (variables, fetchPolicy, onComplete, param) {
91
+ return Curry._2(p.refetch, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(Curry._1(convertRefetchVariables, variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
92
+ };
93
+ }), [p.refetch])
94
+ };
95
+ }
96
+
97
+ function useRefetchableFragment(node, convertFragment, convertRefetchVariables, fRef) {
98
+ var match = ReactRelay.useRefetchableFragment(node, fRef);
99
+ var refetchFn = match[1];
100
+ var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, match[0]);
101
+ return [
102
+ data,
103
+ React.useMemo((function (param) {
104
+ return function (variables, fetchPolicy, onComplete, param) {
105
+ return Curry._2(refetchFn, RescriptRelay_Internal.internal_removeUndefinedAndConvertNullsRaw(Curry._1(convertRefetchVariables, variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
106
+ };
107
+ }), [refetchFn])
108
+ ];
109
+ }
110
+
111
+ exports.useFragment = useFragment;
112
+ exports.useFragmentOpt = useFragmentOpt;
113
+ exports.readInlineData = readInlineData;
114
+ exports.usePaginationFragment = usePaginationFragment;
115
+ exports.useBlockingPaginationFragment = useBlockingPaginationFragment;
116
+ exports.useRefetchableFragment = useRefetchableFragment;
117
+ /* react Not a pure module */
@@ -0,0 +1,239 @@
1
+ open RescriptRelay
2
+
3
+ @module("react-relay")
4
+ external useFragment_: (fragmentNode<'node>, 'fragmentRef) => 'fragment = "useFragment"
5
+
6
+ let useFragment = (~node, ~convertFragment: 'fragment => 'fragment, ~fRef) => {
7
+ /** React hook for getting the data of this fragment. Pass \
8
+ the `fragmentRefs` of any object where you've spread your \
9
+ fragment into this and get the fragment data back.\n\n\
10
+ ### Fragment data outside of React's render\n\
11
+ If you're looking for a way to use fragments _outside_ of \
12
+ render (for regular function calls for instance, like for \
13
+ logging etc), look in to adding `@inline` to your \
14
+ fragment definition (like `fragment SomeFragment_user on \
15
+ User @inline {...}`) and then use `Fragment.readInline`. \
16
+ This will allow you to get the fragment data, but outside \
17
+ of React's render.*/
18
+ (
19
+ useFragment_(node, fRef)
20
+ ->(RescriptRelay_Internal.internal_useConvertedValue(convertFragment, _))
21
+ )
22
+ }
23
+
24
+ @module("react-relay")
25
+ external useFragmentOpt_: (fragmentNode<'node>, option<'fragmentRef>) => Js.Nullable.t<'fragment> =
26
+ "useFragment"
27
+
28
+ let useFragmentOpt = (~fRef, ~node, ~convertFragment: 'fragment => 'fragment) => {
29
+ // TODO(v11) can convert to Nullable pattern match.
30
+
31
+ /** A version of `Fragment.use` that'll allow you to pass \
32
+ `option<fragmentRefs>` and get `option<'fragmentData>` \
33
+ back. Useful for scenarios where you don't have the \
34
+ fragmentRefs yet.*/
35
+ let data =
36
+ useFragmentOpt_(node, fRef)->Js.Nullable.toOption
37
+ React.useMemo1(() => {
38
+ switch data {
39
+ | Some(data) => Some(convertFragment(data))
40
+ | None => None
41
+ }
42
+ }, [data])
43
+ }
44
+
45
+ @module("react-relay")
46
+ external readInlineData_: (fragmentNode<'node>, 'fragmentRef) => 'fragment = "readInlineData"
47
+
48
+ let readInlineData = (~node, ~convertFragment: 'fragment => 'fragment, ~fRef) => {
49
+ /** This lets you get the data for this fragment _outside \
50
+ of React's render_. Useful for letting functions with \
51
+ with fragments too, for things like logging etc.*/
52
+ (readInlineData_(node, fRef)->convertFragment)
53
+ }
54
+
55
+ type refetchableFnOpts = {
56
+ fetchPolicy?: string,
57
+ onComplete?: Js.Nullable.t<Js.Exn.t> => unit,
58
+ }
59
+
60
+ let internal_makeRefetchableFnOpts = (~fetchPolicy=?, ~onComplete=?, ()) => {
61
+ fetchPolicy: ?fetchPolicy->mapFetchPolicy,
62
+ onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler,
63
+ }
64
+
65
+ type paginationLoadMoreOptions = {onComplete?: Js.Nullable.t<Js.Exn.t> => unit}
66
+ type paginationLoadMoreFn = (
67
+ ~count: int,
68
+ ~onComplete: option<Js.Exn.t> => unit=?,
69
+ unit,
70
+ ) => Disposable.t
71
+ type paginationFragmentReturnRaw<'fragment, 'refetchVariables> = {
72
+ data: 'fragment,
73
+ loadNext: (int, paginationLoadMoreOptions) => Disposable.t,
74
+ loadPrevious: (int, paginationLoadMoreOptions) => Disposable.t,
75
+ hasNext: bool,
76
+ hasPrevious: bool,
77
+ isLoadingNext: bool,
78
+ isLoadingPrevious: bool,
79
+ refetch: ('refetchVariables, refetchableFnOpts) => Disposable.t,
80
+ }
81
+ type paginationBlockingFragmentReturn<'fragment, 'refetchVariables> = {
82
+ data: 'fragment,
83
+ loadNext: paginationLoadMoreFn,
84
+ loadPrevious: paginationLoadMoreFn,
85
+ hasNext: bool,
86
+ hasPrevious: bool,
87
+ refetch: (
88
+ ~variables: 'refetchVariables,
89
+ ~fetchPolicy: fetchPolicy=?,
90
+ ~onComplete: option<Js.Exn.t> => unit=?,
91
+ unit,
92
+ ) => Disposable.t,
93
+ }
94
+ type paginationFragmentReturn<'fragment, 'refetchVariables> = {
95
+ data: 'fragment,
96
+ loadNext: paginationLoadMoreFn,
97
+ loadPrevious: paginationLoadMoreFn,
98
+ hasNext: bool,
99
+ hasPrevious: bool,
100
+ isLoadingNext: bool,
101
+ isLoadingPrevious: bool,
102
+ refetch: (
103
+ ~variables: 'refetchVariables,
104
+ ~fetchPolicy: fetchPolicy=?,
105
+ ~onComplete: option<Js.Exn.t> => unit=?,
106
+ unit,
107
+ ) => Disposable.t,
108
+ }
109
+
110
+ @module("react-relay")
111
+ external usePaginationFragment_: (
112
+ fragmentNode<'node>,
113
+ 'fragmentRef,
114
+ ) => paginationFragmentReturnRaw<'fragment, 'refetchVariables> = "usePaginationFragment"
115
+
116
+ /** React hook for paginating a fragment. Paginating with \
117
+ this hook will _not_ cause your component to suspend. \
118
+ If you want pagination to trigger suspense, look into \
119
+ using `Fragment.useBlockingPagination`.*/
120
+ let usePaginationFragment = (
121
+ ~node,
122
+ ~fRef,
123
+ ~convertFragment: 'fragment => 'fragment,
124
+ ~convertRefetchVariables: 'refetchVariables => 'refetchVariables,
125
+ ) => {
126
+ let p = usePaginationFragment_(node, fRef)
127
+ let data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data)
128
+ {
129
+ data,
130
+ loadNext: React.useMemo1(() => (~count, ~onComplete=?, ()) => {
131
+ p.loadNext(
132
+ count,
133
+ {onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler},
134
+ )
135
+ }, [p.loadNext]),
136
+ loadPrevious: React.useMemo1(() => (~count, ~onComplete=?, ()) => {
137
+ p.loadPrevious(
138
+ count,
139
+ {onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler},
140
+ )
141
+ }, [p.loadPrevious]),
142
+ hasNext: p.hasNext,
143
+ hasPrevious: p.hasPrevious,
144
+ isLoadingNext: p.isLoadingNext,
145
+ isLoadingPrevious: p.isLoadingPrevious,
146
+ refetch: React.useMemo1(() => (~variables, ~fetchPolicy=?, ~onComplete=?, ()) => {
147
+ p.refetch(
148
+ RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(
149
+ variables->convertRefetchVariables,
150
+ ),
151
+ internal_makeRefetchableFnOpts(~onComplete?, ~fetchPolicy?, ()),
152
+ )
153
+ }, [p.refetch]),
154
+ }
155
+ }
156
+
157
+ @module("react-relay/lib/relay-hooks/useBlockingPaginationFragment")
158
+ external useBlockingPaginationFragment_: (
159
+ fragmentNode<'node>,
160
+ 'fragmentRef,
161
+ ) => paginationFragmentReturnRaw<'fragment, 'refetchVariables> = "default"
162
+
163
+ /** Like `Fragment.usePagination`, but calling the \
164
+ pagination function will trigger suspense. Useful for \
165
+ all-at-once pagination.*/
166
+ let useBlockingPaginationFragment = (
167
+ ~node,
168
+ ~fRef,
169
+ ~convertFragment: 'fragment => 'fragment,
170
+ ~convertRefetchVariables: 'refetchVariables => 'refetchVariables,
171
+ ) => {
172
+ let p = useBlockingPaginationFragment_(node, fRef)
173
+ let data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data)
174
+ {
175
+ data,
176
+ loadNext: React.useMemo1(() => (~count, ~onComplete=?, ()) => {
177
+ p.loadNext(
178
+ count,
179
+ {onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler},
180
+ )
181
+ }, [p.loadNext]),
182
+ loadPrevious: React.useMemo1(() => (~count, ~onComplete=?, ()) => {
183
+ p.loadPrevious(
184
+ count,
185
+ {onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler},
186
+ )
187
+ }, [p.loadPrevious]),
188
+ hasNext: p.hasNext,
189
+ hasPrevious: p.hasPrevious,
190
+ refetch: React.useMemo1(() => (~variables, ~fetchPolicy=?, ~onComplete=?, ()) => {
191
+ p.refetch(
192
+ RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(
193
+ variables->convertRefetchVariables,
194
+ ),
195
+ internal_makeRefetchableFnOpts(~onComplete?, ~fetchPolicy?, ()),
196
+ )
197
+ }, [p.refetch]),
198
+ }
199
+ }
200
+
201
+ @module("react-relay")
202
+ external useRefetchableFragment_: (
203
+ fragmentNode<'node>,
204
+ 'fragmentRef,
205
+ ) => ('fragment, ('refetchVariables, refetchableFnOpts) => Disposable.t) = "useRefetchableFragment"
206
+
207
+ /**React hook for using a fragment that you want to refetch. Returns \
208
+ a tuple of `(fragmentData, refetchFn)`.\n\n\
209
+ ### Refetching and variables\n\
210
+ You supply a _diff_ of your variables to Relay when refetching. \
211
+ Diffed variables here means that any new value you supply when \
212
+ refetching will be merged with the variables you last used when \
213
+ fetching data for this fragment.\n\n\
214
+ ### `Fragment.makeRefetchVariables` - helper for making the \
215
+ refetch variables\n\
216
+ There's a helper generated for you to create those diffed \
217
+ variables more easily at `Fragment.makeRefetchVariables`.*/
218
+ let useRefetchableFragment = (
219
+ ~node,
220
+ ~convertFragment: 'fragment => 'fragment,
221
+ ~convertRefetchVariables: 'refetchVariables => 'refetchVariables,
222
+ ~fRef,
223
+ ) => {
224
+ let (fragmentData, refetchFn) = useRefetchableFragment_(node, fRef)
225
+ let data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, fragmentData)
226
+ (
227
+ data,
228
+ React.useMemo1(
229
+ () => (~variables: 'refetchVariables, ~fetchPolicy=?, ~onComplete=?, ()) =>
230
+ refetchFn(
231
+ RescriptRelay_Internal.internal_removeUndefinedAndConvertNullsRaw(
232
+ variables->convertRefetchVariables,
233
+ ),
234
+ internal_makeRefetchableFnOpts(~fetchPolicy?, ~onComplete?, ()),
235
+ ),
236
+ [refetchFn],
237
+ ),
238
+ )
239
+ }