rescript-relay 3.0.1 → 3.2.0
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.
- package/CHANGELOG.md +16 -0
- package/package.json +5 -5
- package/ppx-linux +0 -0
- package/ppx-macos-arm64 +0 -0
- package/ppx-macos-latest +0 -0
- package/ppx-windows-latest +0 -0
- package/relay-compiler-linux-musl/relay +0 -0
- package/relay-compiler-linux-x64/relay +0 -0
- package/relay-compiler-macos-arm64/relay +0 -0
- package/relay-compiler-macos-x64/relay +0 -0
- package/relay-compiler-win-x64/relay.exe +0 -0
- package/src/RescriptRelay.bs.js +31 -4
- package/src/RescriptRelay.res +34 -4
- package/src/RescriptRelay.resi +31 -2
- package/src/RescriptRelay_Fragment.bs.js +13 -12
- package/src/RescriptRelay_Fragment.res +65 -31
- package/src/RescriptRelay_Fragment.resi +26 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
+
# 3.2.0
|
|
4
|
+
|
|
5
|
+
- Add support for the new Relay `@catch` directive. https://github.com/zth/rescript-relay/pull/549
|
|
6
|
+
- Add support for `usePrefetchableForwardPagination`. https://github.com/zth/rescript-relay/pull/551
|
|
7
|
+
- Remove `useBlockingPagination` since it's being removed from Relay.
|
|
8
|
+
|
|
9
|
+
# 3.1.0
|
|
10
|
+
|
|
11
|
+
This brings the Relay version to `18.2.0`.
|
|
12
|
+
|
|
13
|
+
If you have enabled the feature flags in `relay.config.js` for aliased fragments or Relay resolvers you'll need to remove them from the config file as they are now on by default, and not removing them will cause the compiler to fail with a non super helpful error message.
|
|
14
|
+
|
|
15
|
+
- **Upgrade versions**: `react-relay` and `relay-runtime` to `18.2.0`.
|
|
16
|
+
- Add support for `Fragment.waitForFragmentData`, a new API in Relay 18.2 that lets you wait for fragment data outside of React.
|
|
17
|
+
- Experimental: Add a "non React" mode to the PPX, which makes sure only APIs that don't rely on React directly are exposed. This is intended to be a way to simplify using RescriptRelay without React. Activate by passing `-non-react` to the PPX, like `"ppx-flags": [["rescript-relay/ppx", "-non-react"]]`.
|
|
18
|
+
|
|
3
19
|
# 3.0.1
|
|
4
20
|
|
|
5
21
|
- Add `Environment.findAllConnectionIds` for finding all IDs of all connection instances for a specific connection, regardless of what configs that connection has been fetched (and cached) with.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rescript-relay",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"main": "src/RescriptRelay.res",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gabriel Nordeborn",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"node-fetch": "^2.6.0",
|
|
50
50
|
"react": "18.2.0",
|
|
51
51
|
"react-dom": "18.2.0",
|
|
52
|
-
"react-relay": "
|
|
53
|
-
"relay-runtime": "
|
|
52
|
+
"react-relay": "18.2.0",
|
|
53
|
+
"relay-runtime": "18.2.0",
|
|
54
54
|
"rescript": "11.1.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@rescript/react": ">=0.13.0",
|
|
58
|
-
"react-relay": "
|
|
59
|
-
"relay-runtime": "
|
|
58
|
+
"react-relay": "18.2.0",
|
|
59
|
+
"relay-runtime": "18.2.0",
|
|
60
60
|
"rescript": "^11.0.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
package/ppx-linux
CHANGED
|
Binary file
|
package/ppx-macos-arm64
CHANGED
|
Binary file
|
package/ppx-macos-latest
CHANGED
|
Binary file
|
package/ppx-windows-latest
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/RescriptRelay.bs.js
CHANGED
|
@@ -10,8 +10,34 @@ var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
|
10
10
|
var ReactRelay = require("react-relay");
|
|
11
11
|
var RelayRuntime = require("relay-runtime");
|
|
12
12
|
var Caml_exceptions = require("rescript/lib/js/caml_exceptions.js");
|
|
13
|
-
var LiveResolverStore = require("relay-runtime/lib/store/
|
|
14
|
-
var LiveResolverStore$1 = require("relay-runtime/lib/store/
|
|
13
|
+
var LiveResolverStore = require("relay-runtime/lib/store/live-resolvers/LiveResolverStore").default;
|
|
14
|
+
var LiveResolverStore$1 = require("relay-runtime/lib/store/live-resolvers/LiveResolverStore");
|
|
15
|
+
|
|
16
|
+
function toOption(t) {
|
|
17
|
+
if (t.ok === true) {
|
|
18
|
+
return Caml_option.some(t.value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function toResult(t) {
|
|
24
|
+
if (t.ok === true) {
|
|
25
|
+
return {
|
|
26
|
+
TAG: "Ok",
|
|
27
|
+
_0: t.value
|
|
28
|
+
};
|
|
29
|
+
} else {
|
|
30
|
+
return {
|
|
31
|
+
TAG: "Error",
|
|
32
|
+
_0: t.errors
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var CatchResult = {
|
|
38
|
+
toOption: toOption,
|
|
39
|
+
toResult: toResult
|
|
40
|
+
};
|
|
15
41
|
|
|
16
42
|
var SuspenseSentinel = {};
|
|
17
43
|
|
|
@@ -209,14 +235,14 @@ function make(source, gcReleaseBufferSize, queryCacheExpirationTime) {
|
|
|
209
235
|
}
|
|
210
236
|
|
|
211
237
|
function makeLiveStore(source, gcReleaseBufferSize, queryCacheExpirationTime) {
|
|
212
|
-
return new LiveResolverStore
|
|
238
|
+
return new LiveResolverStore(source, {
|
|
213
239
|
gcReleaseBufferSize: gcReleaseBufferSize,
|
|
214
240
|
queryCacheExpirationTime: queryCacheExpirationTime
|
|
215
241
|
});
|
|
216
242
|
}
|
|
217
243
|
|
|
218
244
|
function _makeLiveStoreCjs(source, gcReleaseBufferSize, queryCacheExpirationTime) {
|
|
219
|
-
return new LiveResolverStore(source, {
|
|
245
|
+
return new LiveResolverStore$1(source, {
|
|
220
246
|
gcReleaseBufferSize: gcReleaseBufferSize,
|
|
221
247
|
queryCacheExpirationTime: queryCacheExpirationTime
|
|
222
248
|
});
|
|
@@ -345,6 +371,7 @@ function MakeLoadQuery(C) {
|
|
|
345
371
|
|
|
346
372
|
var Mutation_failed = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.Mutation_failed");
|
|
347
373
|
|
|
374
|
+
exports.CatchResult = CatchResult;
|
|
348
375
|
exports.SuspenseSentinel = SuspenseSentinel;
|
|
349
376
|
exports.convertObj = convertObj;
|
|
350
377
|
exports.RecordProxy = RecordProxy;
|
package/src/RescriptRelay.res
CHANGED
|
@@ -17,6 +17,25 @@ type dataIdObject = {id: dataId}
|
|
|
17
17
|
type recordSourceRecords = Js.Json.t
|
|
18
18
|
type uploadables
|
|
19
19
|
|
|
20
|
+
module CatchResult = {
|
|
21
|
+
type catchError = Js.Json.t
|
|
22
|
+
|
|
23
|
+
@tag("ok")
|
|
24
|
+
type t<'value> = | @as(true) Ok({value: 'value}) | @as(false) Error({errors: array<catchError>})
|
|
25
|
+
|
|
26
|
+
let toOption = (t: t<'value>) =>
|
|
27
|
+
switch t {
|
|
28
|
+
| Ok({value}) => Some(value)
|
|
29
|
+
| Error(_) => None
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let toResult = (t: t<'value>): result<'value, array<catchError>> =>
|
|
33
|
+
switch t {
|
|
34
|
+
| Ok({value}) => Ok(value)
|
|
35
|
+
| Error({errors}) => Error(errors)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
20
39
|
module SuspenseSentinel = {
|
|
21
40
|
type t
|
|
22
41
|
|
|
@@ -643,9 +662,9 @@ module Store = {
|
|
|
643
662
|
|
|
644
663
|
@module @new
|
|
645
664
|
external makeLiveStoreCjs: (RecordSource.t, storeConfig) => t =
|
|
646
|
-
"relay-runtime/lib/store/
|
|
665
|
+
"relay-runtime/lib/store/live-resolvers/LiveResolverStore"
|
|
647
666
|
|
|
648
|
-
@module("relay-runtime/lib/store/
|
|
667
|
+
@module("relay-runtime/lib/store/live-resolvers/LiveResolverStore") @new
|
|
649
668
|
external makeLiveStore: (RecordSource.t, storeConfig) => t = "default"
|
|
650
669
|
|
|
651
670
|
@module("relay-runtime") @new
|
|
@@ -686,8 +705,19 @@ module Store = {
|
|
|
686
705
|
module RelayFieldLogger = {
|
|
687
706
|
@tag("kind")
|
|
688
707
|
type arg =
|
|
689
|
-
| @as("
|
|
690
|
-
| @as("
|
|
708
|
+
| @as("missing_required_field.log") MissingRequiredFieldLog({owner: string, fieldPath: string})
|
|
709
|
+
| @as("missing_required_field.throw")
|
|
710
|
+
MissingRequiredFieldThrow({
|
|
711
|
+
owner: string,
|
|
712
|
+
fieldPath: string,
|
|
713
|
+
})
|
|
714
|
+
| @as("missing_expected_data.log") MissingExpectedData({owner: string, fieldPath: string})
|
|
715
|
+
| @as("missing_expected_data.throw")
|
|
716
|
+
MissingExpectedDataThrow({
|
|
717
|
+
owner: string,
|
|
718
|
+
fieldPath: string,
|
|
719
|
+
handled: bool,
|
|
720
|
+
})
|
|
691
721
|
| @as("relay_resolver.error")
|
|
692
722
|
RelayResolverError({
|
|
693
723
|
owner: string,
|
package/src/RescriptRelay.resi
CHANGED
|
@@ -41,6 +41,24 @@ type dataId
|
|
|
41
41
|
|
|
42
42
|
type dataIdObject = {id: dataId}
|
|
43
43
|
|
|
44
|
+
/** A module for results originating from the @catch directive. */
|
|
45
|
+
module CatchResult: {
|
|
46
|
+
/** The shape of an error caught via @catch. */
|
|
47
|
+
type catchError = Js.Json.t
|
|
48
|
+
|
|
49
|
+
/** The result type for @catch. */
|
|
50
|
+
@tag("ok")
|
|
51
|
+
type t<'value> =
|
|
52
|
+
| @as(true) Ok({value: 'value})
|
|
53
|
+
| @as(false) Error({errors: array<catchError>})
|
|
54
|
+
|
|
55
|
+
/** Convert a @catch result to option. */
|
|
56
|
+
let toOption: t<'value> => option<'value>
|
|
57
|
+
|
|
58
|
+
/** Convert a @catch result to result. */
|
|
59
|
+
let toResult: t<'value> => result<'value, array<catchError>>
|
|
60
|
+
}
|
|
61
|
+
|
|
44
62
|
module SuspenseSentinel: {
|
|
45
63
|
type t
|
|
46
64
|
|
|
@@ -744,8 +762,19 @@ module Disposable: {
|
|
|
744
762
|
module RelayFieldLogger: {
|
|
745
763
|
@tag("kind")
|
|
746
764
|
type arg =
|
|
747
|
-
| @as("
|
|
748
|
-
| @as("
|
|
765
|
+
| @as("missing_required_field.log") MissingRequiredFieldLog({owner: string, fieldPath: string})
|
|
766
|
+
| @as("missing_required_field.throw")
|
|
767
|
+
MissingRequiredFieldThrow({
|
|
768
|
+
owner: string,
|
|
769
|
+
fieldPath: string,
|
|
770
|
+
})
|
|
771
|
+
| @as("missing_expected_data.log") MissingExpectedData({owner: string, fieldPath: string})
|
|
772
|
+
| @as("missing_expected_data.throw")
|
|
773
|
+
MissingExpectedDataThrow({
|
|
774
|
+
owner: string,
|
|
775
|
+
fieldPath: string,
|
|
776
|
+
handled: bool,
|
|
777
|
+
})
|
|
749
778
|
| @as("relay_resolver.error")
|
|
750
779
|
RelayResolverError({
|
|
751
780
|
owner: string,
|
|
@@ -5,8 +5,8 @@ var React = require("react");
|
|
|
5
5
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
6
6
|
var ReactRelay = require("react-relay");
|
|
7
7
|
var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
|
|
8
|
+
var Experimental = require("relay-runtime/experimental");
|
|
8
9
|
var ResolverFragments = require("relay-runtime/lib/store/ResolverFragments");
|
|
9
|
-
var UseBlockingPaginationFragment = require("react-relay/lib/relay-hooks/legacy/useBlockingPaginationFragment").default;
|
|
10
10
|
|
|
11
11
|
function useFragment(node, convertFragment, fRef) {
|
|
12
12
|
var __x = ReactRelay.useFragment(node, fRef);
|
|
@@ -69,11 +69,13 @@ function usePaginationFragment(node, fRef, convertFragment, convertRefetchVariab
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function
|
|
73
|
-
var p =
|
|
72
|
+
function usePrefetchableForwardPagination(node, fRef, convertEdges, convertFragment, convertRefetchVariables, bufferSize, initialSize, prefetchingLoadMoreOptions, minimumFetchSize) {
|
|
73
|
+
var p = ReactRelay.usePrefetchableForwardPaginationFragment_EXPERIMENTAL(node, fRef, bufferSize, initialSize !== undefined ? Caml_option.valFromOption(initialSize) : undefined, prefetchingLoadMoreOptions !== undefined ? Caml_option.valFromOption(prefetchingLoadMoreOptions) : undefined, minimumFetchSize !== undefined ? Caml_option.valFromOption(minimumFetchSize) : undefined);
|
|
74
74
|
var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
|
|
75
|
+
var edges = RescriptRelay_Internal.internal_useConvertedValue(convertEdges, p.edges);
|
|
75
76
|
return {
|
|
76
77
|
data: data,
|
|
78
|
+
edges: edges,
|
|
77
79
|
loadNext: React.useMemo((function () {
|
|
78
80
|
return function (count, onComplete) {
|
|
79
81
|
return p.loadNext(count, {
|
|
@@ -81,15 +83,8 @@ function useBlockingPaginationFragment(node, fRef, convertFragment, convertRefet
|
|
|
81
83
|
});
|
|
82
84
|
};
|
|
83
85
|
}), [p.loadNext]),
|
|
84
|
-
loadPrevious: React.useMemo((function () {
|
|
85
|
-
return function (count, onComplete) {
|
|
86
|
-
return p.loadPrevious(count, {
|
|
87
|
-
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
}), [p.loadPrevious]),
|
|
91
86
|
hasNext: p.hasNext,
|
|
92
|
-
|
|
87
|
+
isLoadingNext: p.isLoadingNext,
|
|
93
88
|
refetch: React.useMemo((function () {
|
|
94
89
|
return function (variables, fetchPolicy, onComplete) {
|
|
95
90
|
return p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
@@ -112,11 +107,17 @@ function useRefetchableFragment(node, convertFragment, convertRefetchVariables,
|
|
|
112
107
|
];
|
|
113
108
|
}
|
|
114
109
|
|
|
110
|
+
async function waitForFragmentData(environment, node, convertFragment, fRef) {
|
|
111
|
+
var fragmentData = await Experimental.waitForFragmentData(environment, node, fRef);
|
|
112
|
+
return convertFragment(fragmentData);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
115
|
exports.useFragment = useFragment;
|
|
116
116
|
exports.useFragmentOpt = useFragmentOpt;
|
|
117
117
|
exports.readInlineData = readInlineData;
|
|
118
118
|
exports.read = read;
|
|
119
119
|
exports.usePaginationFragment = usePaginationFragment;
|
|
120
|
-
exports.
|
|
120
|
+
exports.usePrefetchableForwardPagination = usePrefetchableForwardPagination;
|
|
121
121
|
exports.useRefetchableFragment = useRefetchableFragment;
|
|
122
|
+
exports.waitForFragmentData = waitForFragmentData;
|
|
122
123
|
/* react Not a pure module */
|
|
@@ -84,18 +84,6 @@ type paginationFragmentReturnRaw<'fragment, 'refetchVariables> = {
|
|
|
84
84
|
isLoadingPrevious: bool,
|
|
85
85
|
refetch: ('refetchVariables, refetchableFnOpts) => Disposable.t,
|
|
86
86
|
}
|
|
87
|
-
type paginationBlockingFragmentReturn<'fragment, 'refetchVariables> = {
|
|
88
|
-
data: 'fragment,
|
|
89
|
-
loadNext: paginationLoadMoreFn,
|
|
90
|
-
loadPrevious: paginationLoadMoreFn,
|
|
91
|
-
hasNext: bool,
|
|
92
|
-
hasPrevious: bool,
|
|
93
|
-
refetch: (
|
|
94
|
-
~variables: 'refetchVariables,
|
|
95
|
-
~fetchPolicy: fetchPolicy=?,
|
|
96
|
-
~onComplete: option<Js.Exn.t> => unit=?,
|
|
97
|
-
) => Disposable.t,
|
|
98
|
-
}
|
|
99
87
|
type paginationFragmentReturn<'fragment, 'refetchVariables> = {
|
|
100
88
|
data: 'fragment,
|
|
101
89
|
loadNext: paginationLoadMoreFn,
|
|
@@ -117,10 +105,7 @@ external usePaginationFragment_: (
|
|
|
117
105
|
'fragmentRef,
|
|
118
106
|
) => paginationFragmentReturnRaw<'fragment, 'refetchVariables> = "usePaginationFragment"
|
|
119
107
|
|
|
120
|
-
/** React hook for paginating a fragment. Paginating with
|
|
121
|
-
this hook will _not_ cause your component to suspend. \
|
|
122
|
-
If you want pagination to trigger suspense, look into \
|
|
123
|
-
using `Fragment.useBlockingPagination`.*/
|
|
108
|
+
/** React hook for paginating a fragment. Paginating with this hook will _not_ cause your component to suspend. */
|
|
124
109
|
let usePaginationFragment = (
|
|
125
110
|
~node,
|
|
126
111
|
~fRef,
|
|
@@ -158,39 +143,71 @@ let usePaginationFragment = (
|
|
|
158
143
|
}
|
|
159
144
|
}
|
|
160
145
|
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
type prefetchableForwardPaginationFragmentReturnRaw<'fragment, 'edges, 'refetchVariables> = {
|
|
147
|
+
data: 'fragment,
|
|
148
|
+
edges: 'edges,
|
|
149
|
+
loadNext: (int, paginationLoadMoreOptions) => Disposable.t,
|
|
150
|
+
hasNext: bool,
|
|
151
|
+
isLoadingNext: bool,
|
|
152
|
+
refetch: ('refetchVariables, refetchableFnOpts) => Disposable.t,
|
|
153
|
+
}
|
|
154
|
+
type prefetchableForwardPaginationFragmentReturn<'fragment, 'edges, 'refetchVariables> = {
|
|
155
|
+
data: 'fragment,
|
|
156
|
+
edges: 'edges,
|
|
157
|
+
loadNext: paginationLoadMoreFn,
|
|
158
|
+
hasNext: bool,
|
|
159
|
+
isLoadingNext: bool,
|
|
160
|
+
refetch: (
|
|
161
|
+
~variables: 'refetchVariables,
|
|
162
|
+
~fetchPolicy: fetchPolicy=?,
|
|
163
|
+
~onComplete: option<Js.Exn.t> => unit=?,
|
|
164
|
+
) => Disposable.t,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@module("react-relay")
|
|
168
|
+
external usePrefetchableForwardPaginationFragment_: (
|
|
163
169
|
fragmentNode<'node>,
|
|
164
170
|
'fragmentRef,
|
|
165
|
-
|
|
171
|
+
~bufferSize: int,
|
|
172
|
+
~initialSize: int=?,
|
|
173
|
+
~prefetchingLoadMoreOptions: paginationLoadMoreOptions=?,
|
|
174
|
+
~minimumFetchSize: int=?,
|
|
175
|
+
) => prefetchableForwardPaginationFragmentReturnRaw<'fragment, 'edges, 'refetchVariables> =
|
|
176
|
+
"usePrefetchableForwardPaginationFragment_EXPERIMENTAL"
|
|
166
177
|
|
|
167
|
-
/**
|
|
168
|
-
|
|
169
|
-
all-at-once pagination.*/
|
|
170
|
-
let useBlockingPaginationFragment = (
|
|
178
|
+
/** React hook for paginating a fragment. Paginating with this hook will _not_ cause your component to suspend. */
|
|
179
|
+
let usePrefetchableForwardPagination = (
|
|
171
180
|
~node,
|
|
172
181
|
~fRef,
|
|
182
|
+
~convertEdges: 'edges => 'edges,
|
|
173
183
|
~convertFragment: 'fragment => 'fragment,
|
|
174
184
|
~convertRefetchVariables: 'refetchVariables => 'refetchVariables,
|
|
185
|
+
~bufferSize: int,
|
|
186
|
+
~initialSize: option<int>=?,
|
|
187
|
+
~prefetchingLoadMoreOptions: option<paginationLoadMoreOptions>=?,
|
|
188
|
+
~minimumFetchSize: option<int>=?,
|
|
175
189
|
) => {
|
|
176
|
-
let p =
|
|
190
|
+
let p = usePrefetchableForwardPaginationFragment_(
|
|
191
|
+
node,
|
|
192
|
+
fRef,
|
|
193
|
+
~bufferSize,
|
|
194
|
+
~initialSize?,
|
|
195
|
+
~prefetchingLoadMoreOptions?,
|
|
196
|
+
~minimumFetchSize?,
|
|
197
|
+
)
|
|
177
198
|
let data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data)
|
|
199
|
+
let edges = RescriptRelay_Internal.internal_useConvertedValue(convertEdges, p.edges)
|
|
178
200
|
{
|
|
179
201
|
data,
|
|
202
|
+
edges,
|
|
180
203
|
loadNext: React.useMemo1(() => (~count, ~onComplete=?) => {
|
|
181
204
|
p.loadNext(
|
|
182
205
|
count,
|
|
183
206
|
{onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler},
|
|
184
207
|
)
|
|
185
208
|
}, [p.loadNext]),
|
|
186
|
-
loadPrevious: React.useMemo1(() => (~count, ~onComplete=?) => {
|
|
187
|
-
p.loadPrevious(
|
|
188
|
-
count,
|
|
189
|
-
{onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler},
|
|
190
|
-
)
|
|
191
|
-
}, [p.loadPrevious]),
|
|
192
209
|
hasNext: p.hasNext,
|
|
193
|
-
|
|
210
|
+
isLoadingNext: p.isLoadingNext,
|
|
194
211
|
refetch: React.useMemo1(() => (~variables, ~fetchPolicy=?, ~onComplete=?) => {
|
|
195
212
|
p.refetch(
|
|
196
213
|
RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(
|
|
@@ -241,3 +258,20 @@ let useRefetchableFragment = (
|
|
|
241
258
|
),
|
|
242
259
|
)
|
|
243
260
|
}
|
|
261
|
+
|
|
262
|
+
@module("relay-runtime/experimental")
|
|
263
|
+
external waitForFragmentData_: (
|
|
264
|
+
Environment.t,
|
|
265
|
+
fragmentNode<'node>,
|
|
266
|
+
'fragmentRef,
|
|
267
|
+
) => promise<'fragment> = "waitForFragmentData"
|
|
268
|
+
|
|
269
|
+
let waitForFragmentData = async (
|
|
270
|
+
~environment,
|
|
271
|
+
~node,
|
|
272
|
+
~convertFragment: 'fragment => 'fragment,
|
|
273
|
+
~fRef,
|
|
274
|
+
) => {
|
|
275
|
+
let fragmentData = await waitForFragmentData_(environment, node, fRef)
|
|
276
|
+
convertFragment(fragmentData)
|
|
277
|
+
}
|
|
@@ -28,12 +28,14 @@ type paginationLoadMoreOptions = {onComplete?: Js.Nullable.t<Js.Exn.t> => unit}
|
|
|
28
28
|
|
|
29
29
|
type paginationLoadMoreFn = (~count: int, ~onComplete: option<Js.Exn.t> => unit=?) => Disposable.t
|
|
30
30
|
|
|
31
|
-
type
|
|
31
|
+
type paginationFragmentReturn<'fragment, 'refetchVariables> = {
|
|
32
32
|
data: 'fragment,
|
|
33
33
|
loadNext: paginationLoadMoreFn,
|
|
34
34
|
loadPrevious: paginationLoadMoreFn,
|
|
35
35
|
hasNext: bool,
|
|
36
36
|
hasPrevious: bool,
|
|
37
|
+
isLoadingNext: bool,
|
|
38
|
+
isLoadingPrevious: bool,
|
|
37
39
|
refetch: (
|
|
38
40
|
~variables: 'refetchVariables,
|
|
39
41
|
~fetchPolicy: fetchPolicy=?,
|
|
@@ -41,14 +43,19 @@ type paginationBlockingFragmentReturn<'fragment, 'refetchVariables> = {
|
|
|
41
43
|
) => Disposable.t,
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
let usePaginationFragment: (
|
|
47
|
+
~node: fragmentNode<'a>,
|
|
48
|
+
~fRef: 'b,
|
|
49
|
+
~convertFragment: 'fragment => 'fragment,
|
|
50
|
+
~convertRefetchVariables: 'refetchVariables => 'refetchVariables,
|
|
51
|
+
) => paginationFragmentReturn<'fragment, 'refetchVariables>
|
|
52
|
+
|
|
53
|
+
type prefetchableForwardPaginationFragmentReturn<'fragment, 'edges, 'refetchVariables> = {
|
|
45
54
|
data: 'fragment,
|
|
55
|
+
edges: 'edges,
|
|
46
56
|
loadNext: paginationLoadMoreFn,
|
|
47
|
-
loadPrevious: paginationLoadMoreFn,
|
|
48
57
|
hasNext: bool,
|
|
49
|
-
hasPrevious: bool,
|
|
50
58
|
isLoadingNext: bool,
|
|
51
|
-
isLoadingPrevious: bool,
|
|
52
59
|
refetch: (
|
|
53
60
|
~variables: 'refetchVariables,
|
|
54
61
|
~fetchPolicy: fetchPolicy=?,
|
|
@@ -56,19 +63,17 @@ type paginationFragmentReturn<'fragment, 'refetchVariables> = {
|
|
|
56
63
|
) => Disposable.t,
|
|
57
64
|
}
|
|
58
65
|
|
|
59
|
-
let
|
|
60
|
-
~node: fragmentNode<'a>,
|
|
61
|
-
~fRef: 'b,
|
|
62
|
-
~convertFragment: 'fragment => 'fragment,
|
|
63
|
-
~convertRefetchVariables: 'refetchVariables => 'refetchVariables,
|
|
64
|
-
) => paginationFragmentReturn<'fragment, 'refetchVariables>
|
|
65
|
-
|
|
66
|
-
let useBlockingPaginationFragment: (
|
|
66
|
+
let usePrefetchableForwardPagination: (
|
|
67
67
|
~node: fragmentNode<'a>,
|
|
68
68
|
~fRef: 'b,
|
|
69
|
+
~convertEdges: 'edges => 'edges,
|
|
69
70
|
~convertFragment: 'fragment => 'fragment,
|
|
70
71
|
~convertRefetchVariables: 'refetchVariables => 'refetchVariables,
|
|
71
|
-
|
|
72
|
+
~bufferSize: int,
|
|
73
|
+
~initialSize: int=?,
|
|
74
|
+
~prefetchingLoadMoreOptions: paginationLoadMoreOptions=?,
|
|
75
|
+
~minimumFetchSize: int=?,
|
|
76
|
+
) => prefetchableForwardPaginationFragmentReturn<'fragment, 'edges, 'refetchVariables>
|
|
72
77
|
|
|
73
78
|
let useRefetchableFragment: (
|
|
74
79
|
~node: fragmentNode<'a>,
|
|
@@ -83,3 +88,10 @@ let useRefetchableFragment: (
|
|
|
83
88
|
~onComplete: option<Js.Exn.t> => unit=?,
|
|
84
89
|
) => Disposable.t,
|
|
85
90
|
)
|
|
91
|
+
|
|
92
|
+
let waitForFragmentData: (
|
|
93
|
+
~environment: Environment.t,
|
|
94
|
+
~node: fragmentNode<'a>,
|
|
95
|
+
~convertFragment: 'fragment => 'fragment,
|
|
96
|
+
~fRef: 'b,
|
|
97
|
+
) => promise<'fragment>
|