rescript-relay 3.1.0 → 3.3.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 +17 -0
- package/package.json +1 -1
- 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 +35 -4
- package/src/RescriptRelay.res +32 -6
- package/src/RescriptRelay.resi +830 -58
- package/src/RescriptRelay_Fragment.bs.js +6 -12
- package/src/RescriptRelay_Fragment.res +48 -31
- package/src/RescriptRelay_Fragment.resi +19 -14
- package/src/utils.js +6 -0
- package/src/utils.mjs +6 -0
|
@@ -7,7 +7,6 @@ var ReactRelay = require("react-relay");
|
|
|
7
7
|
var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
|
|
8
8
|
var Experimental = require("relay-runtime/experimental");
|
|
9
9
|
var ResolverFragments = require("relay-runtime/lib/store/ResolverFragments");
|
|
10
|
-
var UseBlockingPaginationFragment = require("react-relay/lib/relay-hooks/legacy/useBlockingPaginationFragment").default;
|
|
11
10
|
|
|
12
11
|
function useFragment(node, convertFragment, fRef) {
|
|
13
12
|
var __x = ReactRelay.useFragment(node, fRef);
|
|
@@ -70,11 +69,13 @@ function usePaginationFragment(node, fRef, convertFragment, convertRefetchVariab
|
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
function
|
|
74
|
-
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);
|
|
75
74
|
var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
|
|
75
|
+
var edges = RescriptRelay_Internal.internal_useConvertedValue(convertEdges, p.edges);
|
|
76
76
|
return {
|
|
77
77
|
data: data,
|
|
78
|
+
edges: edges,
|
|
78
79
|
loadNext: React.useMemo((function () {
|
|
79
80
|
return function (count, onComplete) {
|
|
80
81
|
return p.loadNext(count, {
|
|
@@ -82,15 +83,8 @@ function useBlockingPaginationFragment(node, fRef, convertFragment, convertRefet
|
|
|
82
83
|
});
|
|
83
84
|
};
|
|
84
85
|
}), [p.loadNext]),
|
|
85
|
-
loadPrevious: React.useMemo((function () {
|
|
86
|
-
return function (count, onComplete) {
|
|
87
|
-
return p.loadPrevious(count, {
|
|
88
|
-
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
}), [p.loadPrevious]),
|
|
92
86
|
hasNext: p.hasNext,
|
|
93
|
-
|
|
87
|
+
isLoadingNext: p.isLoadingNext,
|
|
94
88
|
refetch: React.useMemo((function () {
|
|
95
89
|
return function (variables, fetchPolicy, onComplete) {
|
|
96
90
|
return p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
@@ -123,7 +117,7 @@ exports.useFragmentOpt = useFragmentOpt;
|
|
|
123
117
|
exports.readInlineData = readInlineData;
|
|
124
118
|
exports.read = read;
|
|
125
119
|
exports.usePaginationFragment = usePaginationFragment;
|
|
126
|
-
exports.
|
|
120
|
+
exports.usePrefetchableForwardPagination = usePrefetchableForwardPagination;
|
|
127
121
|
exports.useRefetchableFragment = useRefetchableFragment;
|
|
128
122
|
exports.waitForFragmentData = waitForFragmentData;
|
|
129
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(
|
|
@@ -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>,
|
package/src/utils.js
CHANGED
|
@@ -79,6 +79,12 @@ function traverse(
|
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
if (currentObj[key] && currentObj[key].BS_PRIVATE_NESTED_SOME_NONE >= 0) {
|
|
83
|
+
newObj = getNewObj(newObj, currentObj);
|
|
84
|
+
newObj[key] = currentObj[key];
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
82
88
|
var shouldConvertRootObj =
|
|
83
89
|
typeof instructions["r"] === "string" &&
|
|
84
90
|
fullInstructionMap[instructions["r"]];
|
package/src/utils.mjs
CHANGED
|
@@ -79,6 +79,12 @@ function traverse(
|
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
if (currentObj[key] && currentObj[key].BS_PRIVATE_NESTED_SOME_NONE >= 0) {
|
|
83
|
+
newObj = getNewObj(newObj, currentObj);
|
|
84
|
+
newObj[key] = currentObj[key];
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
82
88
|
var shouldConvertRootObj =
|
|
83
89
|
typeof instructions["r"] === "string" &&
|
|
84
90
|
fullInstructionMap[instructions["r"]];
|