rescript-relay 1.2.0 → 2.0.0-alpha.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.
- package/CHANGELOG.md +23 -0
- package/README.md +8 -0
- package/package.json +4 -4
- 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-win-x64/relay.exe +0 -0
- package/src/ReactExperimental.bs.js +3 -3
- package/src/RescriptRelay.bs.js +8 -37
- package/src/RescriptRelay.res +20 -36
- package/src/RescriptRelay.resi +28 -22
- package/src/RescriptRelay_Fragment.bs.js +20 -21
- package/src/RescriptRelay_Fragment.res +2 -2
- package/src/RescriptRelay_Internal.bs.js +3 -4
- package/src/RescriptRelay_Mutation.bs.js +42 -39
- package/src/RescriptRelay_Query.bs.js +69 -55
- package/src/RescriptRelay_Query.res +6 -9
- package/src/RescriptRelay_RelayResolvers.bs.js +1 -2
- package/src/RescriptRelay_Subscriptions.bs.js +15 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
+
# 2.0.0-alpha.1
|
|
4
|
+
|
|
5
|
+
## Improvements
|
|
6
|
+
|
|
7
|
+
- `%relay.deferredComponent` now works with uncurried mode.
|
|
8
|
+
|
|
9
|
+
# 2.0.0-alpha.0
|
|
10
|
+
|
|
11
|
+
First alpha of the `2.x` series of releases. `2.x` focuses on compat with ReScript `v11`, including uncurried mode.
|
|
12
|
+
|
|
13
|
+
### Uncurried mode
|
|
14
|
+
|
|
15
|
+
You can activate uncurried mode with `RescriptRelay` by setting `"uncurried": true` in your `bsconfig.json`, and then ensuring that you pass `-uncurried` to `rescript-relay/ppx` in `ppx-flags`: `"ppx-flags": [["rescript-relay/ppx", "-uncurried"]]`.
|
|
16
|
+
|
|
17
|
+
## Upgrade versions
|
|
18
|
+
|
|
19
|
+
- `rescript` to `>=11.0.0-beta.0`
|
|
20
|
+
- `@rescript/react` to `>=0.12.0-alpha.2`
|
|
21
|
+
|
|
22
|
+
## Improvements
|
|
23
|
+
|
|
24
|
+
- Leverage variant's new `string` representation + `@as()` to get rid of `mapFetchPolicy`. This was internal so it should not affect you as an end user.
|
|
25
|
+
|
|
3
26
|
# 1.2.0
|
|
4
27
|
|
|
5
28
|
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).
|
package/README.md
CHANGED
|
@@ -98,6 +98,14 @@ let make = () => {
|
|
|
98
98
|
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
## Note about versioning
|
|
102
|
+
|
|
103
|
+
There's plenty of work ongoing to bring RescriptRelay to full ReScript v11 support, including uncurried mode. Here's the versioning scheme that'll be followed going forward:
|
|
104
|
+
|
|
105
|
+
- 1.x will receive critical bug fixes etc, but new features won't be added
|
|
106
|
+
- 2.x will soon ship, and it'll focus on compatibility with ReScript v11, and uncurried mode (uncurried mode will be optional). This is intended to make the transition to v11+ smooth
|
|
107
|
+
- 3.x will also soon ship, and that'll fully embrace uncurried mode (no curried mode available), and add a bunch of new stuff + change existing APIs to make them better and more ergonomic
|
|
108
|
+
|
|
101
109
|
## Examples
|
|
102
110
|
|
|
103
111
|
- A general example showcasing most available features: https://github.com/zth/rescript-relay/tree/master/example
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rescript-relay",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"main": "src/RescriptRelay.res",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gabriel Nordeborn",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"react-dom": "18.2.0",
|
|
52
52
|
"react-relay": "15.0.0",
|
|
53
53
|
"relay-runtime": "15.0.0",
|
|
54
|
-
"rescript": "^11.0.0-beta.
|
|
54
|
+
"rescript": "^11.0.0-beta.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@rescript/react": "
|
|
57
|
+
"@rescript/react": "^0.12.0-alpha.2 || next",
|
|
58
58
|
"react-relay": ">=15.0.0",
|
|
59
59
|
"relay-runtime": "*",
|
|
60
|
-
"rescript": "
|
|
60
|
+
"rescript": "^11.0.0-alpha.0 || next"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"detect-libc": "^2.0.1"
|
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
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
var React = require("react");
|
|
5
5
|
|
|
6
|
-
function useTransition(
|
|
6
|
+
function useTransition() {
|
|
7
7
|
var match = React.useTransition();
|
|
8
8
|
var startTransition = match[1];
|
|
9
9
|
return [
|
|
10
10
|
match[0],
|
|
11
|
-
React.useMemo((function (
|
|
11
|
+
React.useMemo((function () {
|
|
12
12
|
return function (cb) {
|
|
13
|
-
|
|
13
|
+
startTransition(cb, undefined);
|
|
14
14
|
};
|
|
15
15
|
}), [startTransition])
|
|
16
16
|
];
|
package/src/RescriptRelay.bs.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var Curry = require("rescript/lib/js/curry.js");
|
|
5
4
|
var React = require("react");
|
|
6
5
|
var Utils = require("./utils");
|
|
7
6
|
var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
@@ -130,8 +129,10 @@ var Store = {
|
|
|
130
129
|
make: make
|
|
131
130
|
};
|
|
132
131
|
|
|
133
|
-
function toJs(f
|
|
134
|
-
|
|
132
|
+
function toJs(f) {
|
|
133
|
+
return function (arg) {
|
|
134
|
+
f(arg.kind, arg.owner, arg.fieldPath);
|
|
135
|
+
};
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFieldHandlers, requiredFieldLogger, isServer, param) {
|
|
@@ -180,7 +181,7 @@ var Context = {
|
|
|
180
181
|
|
|
181
182
|
var EnvironmentNotFoundInContext = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.EnvironmentNotFoundInContext");
|
|
182
183
|
|
|
183
|
-
function useEnvironmentFromContext(
|
|
184
|
+
function useEnvironmentFromContext() {
|
|
184
185
|
var context = React.useContext(ReactRelay.ReactRelayContext);
|
|
185
186
|
if (context !== undefined) {
|
|
186
187
|
return Caml_option.valFromOption(context).environment;
|
|
@@ -191,39 +192,11 @@ function useEnvironmentFromContext(param) {
|
|
|
191
192
|
};
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
function mapFetchPolicy(x) {
|
|
195
|
-
if (x === undefined) {
|
|
196
|
-
return ;
|
|
197
|
-
}
|
|
198
|
-
switch (x) {
|
|
199
|
-
case "StoreOnly" :
|
|
200
|
-
return "store-only";
|
|
201
|
-
case "StoreOrNetwork" :
|
|
202
|
-
return "store-or-network";
|
|
203
|
-
case "StoreAndNetwork" :
|
|
204
|
-
return "store-and-network";
|
|
205
|
-
case "NetworkOnly" :
|
|
206
|
-
return "network-only";
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function mapFetchQueryFetchPolicy(x) {
|
|
212
|
-
if (x !== undefined) {
|
|
213
|
-
if (x === "NetworkOnly") {
|
|
214
|
-
return "network-only";
|
|
215
|
-
} else {
|
|
216
|
-
return "store-or-network";
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
195
|
function MakeLoadQuery(C) {
|
|
223
196
|
var load = function (environment, variables, fetchPolicy, fetchKey, networkCacheConfig, param) {
|
|
224
|
-
return ReactRelay.loadQuery(environment, C.query,
|
|
197
|
+
return ReactRelay.loadQuery(environment, C.query, C.convertVariables(variables), {
|
|
225
198
|
fetchKey: fetchKey,
|
|
226
|
-
fetchPolicy:
|
|
199
|
+
fetchPolicy: fetchPolicy,
|
|
227
200
|
networkCacheConfig: networkCacheConfig
|
|
228
201
|
});
|
|
229
202
|
};
|
|
@@ -235,7 +208,7 @@ function MakeLoadQuery(C) {
|
|
|
235
208
|
var o = queryRefToObservable(token);
|
|
236
209
|
if (o !== undefined) {
|
|
237
210
|
Caml_option.valFromOption(o).subscribe({
|
|
238
|
-
complete: (function (
|
|
211
|
+
complete: (function () {
|
|
239
212
|
resolve({
|
|
240
213
|
TAG: "Ok",
|
|
241
214
|
_0: undefined
|
|
@@ -275,8 +248,6 @@ exports.Store = Store;
|
|
|
275
248
|
exports.Disposable = Disposable;
|
|
276
249
|
exports.RequiredFieldLogger = RequiredFieldLogger;
|
|
277
250
|
exports.Environment = Environment;
|
|
278
|
-
exports.mapFetchPolicy = mapFetchPolicy;
|
|
279
|
-
exports.mapFetchQueryFetchPolicy = mapFetchQueryFetchPolicy;
|
|
280
251
|
exports.Context = Context;
|
|
281
252
|
exports.EnvironmentNotFoundInContext = EnvironmentNotFoundInContext;
|
|
282
253
|
exports.useEnvironmentFromContext = useEnvironmentFromContext;
|
package/src/RescriptRelay.res
CHANGED
|
@@ -482,9 +482,9 @@ module Observable = {
|
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
type sink<'response> = {
|
|
485
|
-
next:
|
|
486
|
-
error:
|
|
487
|
-
complete:
|
|
485
|
+
next: 'response => unit,
|
|
486
|
+
error: Js.Exn.t => unit,
|
|
487
|
+
complete: unit => unit,
|
|
488
488
|
closed: bool,
|
|
489
489
|
}
|
|
490
490
|
|
|
@@ -492,11 +492,11 @@ module Observable = {
|
|
|
492
492
|
|
|
493
493
|
@obj
|
|
494
494
|
external makeObserver: (
|
|
495
|
-
~start:
|
|
496
|
-
~next:
|
|
497
|
-
~error:
|
|
498
|
-
~complete:
|
|
499
|
-
~unsubscribe:
|
|
495
|
+
~start: subscription => unit=?,
|
|
496
|
+
~next: 'response => unit=?,
|
|
497
|
+
~error: Js.Exn.t => unit=?,
|
|
498
|
+
~complete: unit => unit=?,
|
|
499
|
+
~unsubscribe: subscription => unit=?,
|
|
500
500
|
unit,
|
|
501
501
|
) => observer<'response> = ""
|
|
502
502
|
|
|
@@ -681,39 +681,23 @@ let useEnvironmentFromContext = () => {
|
|
|
681
681
|
}
|
|
682
682
|
|
|
683
683
|
type fetchPolicy =
|
|
684
|
-
| StoreOnly
|
|
685
|
-
| StoreOrNetwork
|
|
686
|
-
| StoreAndNetwork
|
|
687
|
-
| NetworkOnly
|
|
688
|
-
|
|
689
|
-
let mapFetchPolicy = x =>
|
|
690
|
-
switch x {
|
|
691
|
-
| Some(StoreOnly) => Some("store-only")
|
|
692
|
-
| Some(StoreOrNetwork) => Some("store-or-network")
|
|
693
|
-
| Some(StoreAndNetwork) => Some("store-and-network")
|
|
694
|
-
| Some(NetworkOnly) => Some("network-only")
|
|
695
|
-
| None => None
|
|
696
|
-
}
|
|
684
|
+
| @as("store-only") StoreOnly
|
|
685
|
+
| @as("store-or-network") StoreOrNetwork
|
|
686
|
+
| @as("store-and-network") StoreAndNetwork
|
|
687
|
+
| @as("network-only") NetworkOnly
|
|
697
688
|
|
|
698
689
|
type fetchQueryFetchPolicy =
|
|
699
|
-
| NetworkOnly
|
|
700
|
-
| StoreOrNetwork
|
|
701
|
-
|
|
702
|
-
let mapFetchQueryFetchPolicy = x =>
|
|
703
|
-
switch x {
|
|
704
|
-
| Some(StoreOrNetwork) => Some("store-or-network")
|
|
705
|
-
| Some(NetworkOnly) => Some("network-only")
|
|
706
|
-
| None => None
|
|
707
|
-
}
|
|
690
|
+
| @as("network-only") NetworkOnly
|
|
691
|
+
| @as("store-or-network") StoreOrNetwork
|
|
708
692
|
|
|
709
693
|
type fetchQueryOptions = {
|
|
710
|
-
networkCacheConfig
|
|
711
|
-
fetchPolicy
|
|
694
|
+
networkCacheConfig?: cacheConfig,
|
|
695
|
+
fetchPolicy?: fetchPolicy,
|
|
712
696
|
}
|
|
713
697
|
|
|
714
698
|
type loadQueryConfig = {
|
|
715
699
|
fetchKey: option<string>,
|
|
716
|
-
fetchPolicy: option<
|
|
700
|
+
fetchPolicy: option<fetchPolicy>,
|
|
717
701
|
networkCacheConfig: option<cacheConfig>,
|
|
718
702
|
}
|
|
719
703
|
|
|
@@ -752,7 +736,7 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
|
|
|
752
736
|
variables->C.convertVariables,
|
|
753
737
|
{
|
|
754
738
|
fetchKey,
|
|
755
|
-
fetchPolicy
|
|
739
|
+
fetchPolicy,
|
|
756
740
|
networkCacheConfig,
|
|
757
741
|
},
|
|
758
742
|
)
|
|
@@ -768,10 +752,10 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
|
|
|
768
752
|
let queryRefToPromise = token => {
|
|
769
753
|
Js.Promise.make((~resolve, ~reject as _) => {
|
|
770
754
|
switch token->queryRefToObservable {
|
|
771
|
-
| None => resolve(
|
|
755
|
+
| None => resolve(Error())
|
|
772
756
|
| Some(o) =>
|
|
773
757
|
open Observable
|
|
774
|
-
let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(
|
|
758
|
+
let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(Ok()), ()))
|
|
775
759
|
}
|
|
776
760
|
})
|
|
777
761
|
}
|
package/src/RescriptRelay.resi
CHANGED
|
@@ -132,7 +132,7 @@ module RecordProxy: {
|
|
|
132
132
|
@send
|
|
133
133
|
external copyFieldsFrom: (t, ~sourceRecord: t) => unit = "copyFieldsFrom"
|
|
134
134
|
|
|
135
|
-
/**Gets the
|
|
135
|
+
/**Gets the `dataId` for a particular record.*/
|
|
136
136
|
@send
|
|
137
137
|
external getDataId: t => dataId = "getDataID"
|
|
138
138
|
|
|
@@ -577,9 +577,9 @@ module Observable: {
|
|
|
577
577
|
|
|
578
578
|
/**This sink can be used to give the observable new data.*/
|
|
579
579
|
type sink<'response> = {
|
|
580
|
-
next:
|
|
581
|
-
error:
|
|
582
|
-
complete:
|
|
580
|
+
next: 'response => unit,
|
|
581
|
+
error: Js.Exn.t => unit,
|
|
582
|
+
complete: unit => unit,
|
|
583
583
|
closed: bool,
|
|
584
584
|
}
|
|
585
585
|
|
|
@@ -595,10 +595,10 @@ module Observable: {
|
|
|
595
595
|
/**Create an observer.*/
|
|
596
596
|
@obj
|
|
597
597
|
external makeObserver: (
|
|
598
|
-
~start:
|
|
599
|
-
~next:
|
|
600
|
-
~error:
|
|
601
|
-
~complete:
|
|
598
|
+
~start: subscription => unit=?,
|
|
599
|
+
~next: 'response => unit=?,
|
|
600
|
+
~error: Js.Exn.t => unit=?,
|
|
601
|
+
~complete: unit => unit=?,
|
|
602
602
|
~unsubscribe: subscription => unit=?,
|
|
603
603
|
unit,
|
|
604
604
|
) => observer<'response> = ""
|
|
@@ -771,21 +771,27 @@ You should use the generated `Query.retain` function on your queries instead of
|
|
|
771
771
|
|
|
772
772
|
/**fetchPolicy controls how you want Relay to resolve your data.*/
|
|
773
773
|
type fetchPolicy =
|
|
774
|
-
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
774
|
+
| /** will only reuse locally cached data, and will never send a network request to fetch the query. In this case, the responsibility of fetching the query falls to the caller, but this policy could also be used to read and operate on data that is entirely local. */
|
|
775
|
+
@as("store-only")
|
|
776
|
+
StoreOnly
|
|
777
|
+
| /** (default) will reuse locally cached data, and will only send a network request if any data for the query is missing or stale. If the query is fully cached, a network request will not be made.*/
|
|
778
|
+
@as("store-or-network")
|
|
779
|
+
StoreOrNetwork
|
|
780
|
+
| /** will reuse locally cached data and will always send a network request, regardless of whether any data was missing or stale in the store. */
|
|
781
|
+
@as("store-and-network")
|
|
782
|
+
StoreAndNetwork
|
|
783
|
+
| /** will not reuse locally cached data, and will always send a network request to fetch the query, ignoring any data that might be locally cached and whether it's missing or stale. */
|
|
784
|
+
@as("network-only")
|
|
785
|
+
NetworkOnly
|
|
781
786
|
|
|
782
787
|
/**The fetch policies allowed for fetching a query outside of React's render (as in `Query.fetch`).*/
|
|
783
788
|
type fetchQueryFetchPolicy =
|
|
784
|
-
|
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
|
|
789
|
+
| /** will not reuse locally cached data, and will always send a network request to fetch the query, ignoring any data that might be locally cached and whether it's missing or stale. */
|
|
790
|
+
@as("network-only")
|
|
791
|
+
NetworkOnly
|
|
792
|
+
| /** (default) will reuse locally cached data, and will only send a network request if any data for the query is missing or stale. If the query is fully cached, a network request will not be made.*/
|
|
793
|
+
@as("store-or-network")
|
|
794
|
+
StoreOrNetwork
|
|
789
795
|
|
|
790
796
|
/**An error from a mutation.*/
|
|
791
797
|
type mutationError = {message: string}
|
|
@@ -835,8 +841,8 @@ external useSubscribeToInvalidationState: (array<dataId>, unit => unit) => Dispo
|
|
|
835
841
|
|
|
836
842
|
/**Options valid when fetching a query outside of React's render method (like when using `Query.fetch`).*/
|
|
837
843
|
type fetchQueryOptions = {
|
|
838
|
-
networkCacheConfig
|
|
839
|
-
fetchPolicy
|
|
844
|
+
networkCacheConfig?: cacheConfig,
|
|
845
|
+
fetchPolicy?: fetchPolicy,
|
|
840
846
|
}
|
|
841
847
|
|
|
842
848
|
module type MakeLoadQueryConfig = {
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var Curry = require("rescript/lib/js/curry.js");
|
|
5
4
|
var React = require("react");
|
|
6
5
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
7
6
|
var ReactRelay = require("react-relay");
|
|
8
|
-
var RescriptRelay = require("./RescriptRelay.bs.js");
|
|
9
7
|
var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
|
|
10
8
|
|
|
11
9
|
function useFragment(node, convertFragment, fRef) {
|
|
12
|
-
|
|
10
|
+
var __x = ReactRelay.useFragment(node, fRef);
|
|
11
|
+
return RescriptRelay_Internal.internal_useConvertedValue(convertFragment, __x);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
function useFragmentOpt(fRef, node, convertFragment) {
|
|
16
15
|
var data = ReactRelay.useFragment(node, fRef);
|
|
17
|
-
return React.useMemo((function (
|
|
16
|
+
return React.useMemo((function () {
|
|
18
17
|
if (!(data == null)) {
|
|
19
|
-
return Caml_option.some(
|
|
18
|
+
return Caml_option.some(convertFragment(data));
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
}), [(data == null) ? undefined : Caml_option.some(data)]);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
function readInlineData(node, convertFragment, fRef) {
|
|
26
|
-
return
|
|
25
|
+
return convertFragment(ReactRelay.readInlineData(node, fRef));
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
function internal_makeRefetchableFnOpts(fetchPolicy, onComplete, param) {
|
|
30
29
|
return {
|
|
31
|
-
fetchPolicy:
|
|
30
|
+
fetchPolicy: fetchPolicy,
|
|
32
31
|
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
33
32
|
};
|
|
34
33
|
}
|
|
@@ -38,16 +37,16 @@ function usePaginationFragment(node, fRef, convertFragment, convertRefetchVariab
|
|
|
38
37
|
var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
|
|
39
38
|
return {
|
|
40
39
|
data: data,
|
|
41
|
-
loadNext: React.useMemo((function (
|
|
40
|
+
loadNext: React.useMemo((function () {
|
|
42
41
|
return function (count, onComplete, param) {
|
|
43
|
-
return
|
|
42
|
+
return p.loadNext(count, {
|
|
44
43
|
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
45
44
|
});
|
|
46
45
|
};
|
|
47
46
|
}), [p.loadNext]),
|
|
48
|
-
loadPrevious: React.useMemo((function (
|
|
47
|
+
loadPrevious: React.useMemo((function () {
|
|
49
48
|
return function (count, onComplete, param) {
|
|
50
|
-
return
|
|
49
|
+
return p.loadPrevious(count, {
|
|
51
50
|
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
52
51
|
});
|
|
53
52
|
};
|
|
@@ -56,9 +55,9 @@ function usePaginationFragment(node, fRef, convertFragment, convertRefetchVariab
|
|
|
56
55
|
hasPrevious: p.hasPrevious,
|
|
57
56
|
isLoadingNext: p.isLoadingNext,
|
|
58
57
|
isLoadingPrevious: p.isLoadingPrevious,
|
|
59
|
-
refetch: React.useMemo((function (
|
|
58
|
+
refetch: React.useMemo((function () {
|
|
60
59
|
return function (variables, fetchPolicy, onComplete, param) {
|
|
61
|
-
return
|
|
60
|
+
return p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
62
61
|
};
|
|
63
62
|
}), [p.refetch])
|
|
64
63
|
};
|
|
@@ -69,25 +68,25 @@ function useBlockingPaginationFragment(node, fRef, convertFragment, convertRefet
|
|
|
69
68
|
var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
|
|
70
69
|
return {
|
|
71
70
|
data: data,
|
|
72
|
-
loadNext: React.useMemo((function (
|
|
71
|
+
loadNext: React.useMemo((function () {
|
|
73
72
|
return function (count, onComplete, param) {
|
|
74
|
-
return
|
|
73
|
+
return p.loadNext(count, {
|
|
75
74
|
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
76
75
|
});
|
|
77
76
|
};
|
|
78
77
|
}), [p.loadNext]),
|
|
79
|
-
loadPrevious: React.useMemo((function (
|
|
78
|
+
loadPrevious: React.useMemo((function () {
|
|
80
79
|
return function (count, onComplete, param) {
|
|
81
|
-
return
|
|
80
|
+
return p.loadPrevious(count, {
|
|
82
81
|
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
83
82
|
});
|
|
84
83
|
};
|
|
85
84
|
}), [p.loadPrevious]),
|
|
86
85
|
hasNext: p.hasNext,
|
|
87
86
|
hasPrevious: p.hasPrevious,
|
|
88
|
-
refetch: React.useMemo((function (
|
|
87
|
+
refetch: React.useMemo((function () {
|
|
89
88
|
return function (variables, fetchPolicy, onComplete, param) {
|
|
90
|
-
return
|
|
89
|
+
return p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
91
90
|
};
|
|
92
91
|
}), [p.refetch])
|
|
93
92
|
};
|
|
@@ -99,9 +98,9 @@ function useRefetchableFragment(node, convertFragment, convertRefetchVariables,
|
|
|
99
98
|
var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, match[0]);
|
|
100
99
|
return [
|
|
101
100
|
data,
|
|
102
|
-
React.useMemo((function (
|
|
101
|
+
React.useMemo((function () {
|
|
103
102
|
return function (variables, fetchPolicy, onComplete, param) {
|
|
104
|
-
return
|
|
103
|
+
return refetchFn(RescriptRelay_Internal.internal_removeUndefinedAndConvertNullsRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
105
104
|
};
|
|
106
105
|
}), [refetchFn])
|
|
107
106
|
];
|
|
@@ -53,12 +53,12 @@ let readInlineData = (~node, ~convertFragment: 'fragment => 'fragment, ~fRef) =>
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
type refetchableFnOpts = {
|
|
56
|
-
fetchPolicy?:
|
|
56
|
+
fetchPolicy?: fetchPolicy,
|
|
57
57
|
onComplete?: Js.Nullable.t<Js.Exn.t> => unit,
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
let internal_makeRefetchableFnOpts = (~fetchPolicy=?, ~onComplete=?, ()) => {
|
|
61
|
-
|
|
61
|
+
?fetchPolicy,
|
|
62
62
|
onComplete: ?onComplete->RescriptRelay_Internal.internal_nullableToOptionalExnHandler,
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var Curry = require("rescript/lib/js/curry.js");
|
|
5
4
|
var React = require("react");
|
|
6
5
|
var Js_dict = require("rescript/lib/js/js_dict.js");
|
|
7
6
|
var Caml_obj = require("rescript/lib/js/caml_obj.js");
|
|
@@ -55,15 +54,15 @@ function internal_removeUndefinedAndConvertNullsRaw(record) {
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
function internal_useConvertedValue(convert, v) {
|
|
58
|
-
return React.useMemo((function (
|
|
59
|
-
return
|
|
57
|
+
return React.useMemo((function () {
|
|
58
|
+
return convert(v);
|
|
60
59
|
}), [v]);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
function internal_nullableToOptionalExnHandler(x) {
|
|
64
63
|
if (x !== undefined) {
|
|
65
64
|
return (function (maybeExn) {
|
|
66
|
-
return
|
|
65
|
+
return x((maybeExn == null) ? undefined : Caml_option.some(maybeExn));
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
68
|
|
|
@@ -1,52 +1,55 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var Curry = require("rescript/lib/js/curry.js");
|
|
5
4
|
var React = require("react");
|
|
6
5
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
7
6
|
var ReactRelay = require("react-relay");
|
|
8
7
|
var RelayRuntime = require("relay-runtime");
|
|
9
8
|
|
|
10
|
-
function commitMutation(convertVariables, node, convertResponse, convertWrapRawResponse
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
function commitMutation(convertVariables, node, convertResponse, convertWrapRawResponse) {
|
|
10
|
+
return function (environment, variables, optimisticUpdater, optimisticResponse, updater, onCompleted, onError, uploadables, param) {
|
|
11
|
+
return RelayRuntime.commitMutation(environment, {
|
|
12
|
+
mutation: node,
|
|
13
|
+
variables: convertVariables(variables),
|
|
14
|
+
onCompleted: onCompleted !== undefined ? (function (res, err) {
|
|
15
|
+
onCompleted(convertResponse(res), (err == null) ? undefined : Caml_option.some(err));
|
|
16
|
+
}) : undefined,
|
|
17
|
+
onError: onError,
|
|
18
|
+
optimisticResponse: optimisticResponse !== undefined ? Caml_option.some(convertWrapRawResponse(Caml_option.valFromOption(optimisticResponse))) : undefined,
|
|
19
|
+
optimisticUpdater: optimisticUpdater,
|
|
20
|
+
updater: updater !== undefined ? (function (store, response) {
|
|
21
|
+
updater(store, convertResponse(response));
|
|
22
|
+
}) : undefined,
|
|
23
|
+
uploadables: uploadables
|
|
24
|
+
});
|
|
25
|
+
};
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function useMutation(convertVariables, node, convertResponse, convertWrapRawResponse
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
function useMutation(convertVariables, node, convertResponse, convertWrapRawResponse) {
|
|
29
|
+
return function () {
|
|
30
|
+
var match = ReactRelay.useMutation(node);
|
|
31
|
+
var mutate = match[0];
|
|
32
|
+
return [
|
|
33
|
+
React.useMemo((function () {
|
|
34
|
+
return function (variables, optimisticUpdater, optimisticResponse, updater, onCompleted, onError, uploadables, param) {
|
|
35
|
+
return mutate({
|
|
36
|
+
onError: onError,
|
|
37
|
+
onCompleted: onCompleted !== undefined ? (function (res, err) {
|
|
38
|
+
onCompleted(convertResponse(res), (err == null) ? undefined : Caml_option.some(err));
|
|
39
|
+
}) : undefined,
|
|
40
|
+
optimisticResponse: optimisticResponse !== undefined ? Caml_option.some(convertWrapRawResponse(Caml_option.valFromOption(optimisticResponse))) : undefined,
|
|
41
|
+
optimisticUpdater: optimisticUpdater,
|
|
42
|
+
updater: updater !== undefined ? (function (store, response) {
|
|
43
|
+
updater(store, convertResponse(response));
|
|
44
|
+
}) : undefined,
|
|
45
|
+
variables: convertVariables(variables),
|
|
46
|
+
uploadables: uploadables
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
}), [mutate]),
|
|
50
|
+
match[1]
|
|
51
|
+
];
|
|
52
|
+
};
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
exports.commitMutation = commitMutation;
|
|
@@ -1,80 +1,94 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var Curry = require("rescript/lib/js/curry.js");
|
|
5
4
|
var React = require("react");
|
|
6
5
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
7
6
|
var Js_promise2 = require("rescript/lib/js/js_promise2.js");
|
|
8
7
|
var ReactRelay = require("react-relay");
|
|
9
|
-
var RescriptRelay = require("./RescriptRelay.bs.js");
|
|
10
8
|
var RelayRuntime = require("relay-runtime");
|
|
11
9
|
var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
|
|
12
10
|
|
|
13
|
-
function useQuery(convertVariables, node, convertResponse
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
function useQuery(convertVariables, node, convertResponse) {
|
|
12
|
+
return function (variables, fetchPolicy, fetchKey, networkCacheConfig, param) {
|
|
13
|
+
var __x = ReactRelay.useLazyLoadQuery(node, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertVariables(variables)), {
|
|
14
|
+
fetchKey: fetchKey,
|
|
15
|
+
fetchPolicy: fetchPolicy,
|
|
16
|
+
networkCacheConfig: networkCacheConfig
|
|
17
|
+
});
|
|
18
|
+
return RescriptRelay_Internal.internal_useConvertedValue(convertResponse, __x);
|
|
19
|
+
};
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
function useLoader(convertVariables, node, mkQueryRef
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
function useLoader(convertVariables, node, mkQueryRef) {
|
|
23
|
+
return function () {
|
|
24
|
+
var match = ReactRelay.useQueryLoader(node);
|
|
25
|
+
var loadQueryFn = match[1];
|
|
26
|
+
var loadQuery = React.useMemo((function () {
|
|
27
|
+
return function (variables, fetchPolicy, networkCacheConfig, param) {
|
|
28
|
+
loadQueryFn(convertVariables(variables), {
|
|
29
|
+
fetchPolicy: fetchPolicy,
|
|
30
|
+
networkCacheConfig: networkCacheConfig
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
}), [loadQueryFn]);
|
|
34
|
+
return [
|
|
35
|
+
mkQueryRef(Caml_option.nullable_to_opt(match[0])),
|
|
36
|
+
loadQuery,
|
|
37
|
+
match[2]
|
|
38
|
+
];
|
|
39
|
+
};
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
function usePreloaded(node, convertResponse, mkQueryRef
|
|
40
|
-
return
|
|
42
|
+
function usePreloaded(node, convertResponse, mkQueryRef) {
|
|
43
|
+
return function (queryRef) {
|
|
44
|
+
var __x = ReactRelay.usePreloadedQuery(node, mkQueryRef(queryRef));
|
|
45
|
+
return RescriptRelay_Internal.internal_useConvertedValue(convertResponse, __x);
|
|
46
|
+
};
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
function $$fetch(node, convertResponse, convertVariables
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
function $$fetch(node, convertResponse, convertVariables) {
|
|
50
|
+
return function (environment, variables, onResult, networkCacheConfig, fetchPolicy, param) {
|
|
51
|
+
ReactRelay.fetchQuery(environment, node, convertVariables(variables), {
|
|
52
|
+
networkCacheConfig: networkCacheConfig,
|
|
53
|
+
fetchPolicy: fetchPolicy
|
|
54
|
+
}).subscribe({
|
|
55
|
+
next: (function (res) {
|
|
56
|
+
onResult({
|
|
57
|
+
TAG: "Ok",
|
|
58
|
+
_0: convertResponse(res)
|
|
59
|
+
});
|
|
60
|
+
}),
|
|
61
|
+
error: (function (err) {
|
|
62
|
+
onResult({
|
|
63
|
+
TAG: "Error",
|
|
64
|
+
_0: err
|
|
65
|
+
});
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
};
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
function fetchPromised(node, convertResponse, convertVariables
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
function fetchPromised(node, convertResponse, convertVariables) {
|
|
72
|
+
return function (environment, variables, networkCacheConfig, fetchPolicy, param) {
|
|
73
|
+
return Js_promise2.then(ReactRelay.fetchQuery(environment, node, convertVariables(variables), {
|
|
74
|
+
networkCacheConfig: networkCacheConfig,
|
|
75
|
+
fetchPolicy: fetchPolicy
|
|
76
|
+
}).toPromise(), (function (res) {
|
|
77
|
+
return Promise.resolve(convertResponse(res));
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
70
80
|
}
|
|
71
81
|
|
|
72
|
-
function retain(node, convertVariables
|
|
73
|
-
return
|
|
82
|
+
function retain(node, convertVariables) {
|
|
83
|
+
return function (environment, variables) {
|
|
84
|
+
return environment.retain(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)));
|
|
85
|
+
};
|
|
74
86
|
}
|
|
75
87
|
|
|
76
|
-
function commitLocalPayload(node, convertVariables, convertWrapRawResponse
|
|
77
|
-
|
|
88
|
+
function commitLocalPayload(node, convertVariables, convertWrapRawResponse) {
|
|
89
|
+
return function (environment, variables, payload) {
|
|
90
|
+
environment.commitPayload(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)), convertWrapRawResponse(payload));
|
|
91
|
+
};
|
|
78
92
|
}
|
|
79
93
|
|
|
80
94
|
exports.useQuery = useQuery;
|
|
@@ -2,7 +2,7 @@ open RescriptRelay
|
|
|
2
2
|
|
|
3
3
|
type useQueryConfig = {
|
|
4
4
|
fetchKey?: string,
|
|
5
|
-
fetchPolicy?:
|
|
5
|
+
fetchPolicy?: fetchPolicy,
|
|
6
6
|
networkCacheConfig?: cacheConfig,
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -28,7 +28,7 @@ let useQuery = (
|
|
|
28
28
|
RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(variables->convertVariables),
|
|
29
29
|
{
|
|
30
30
|
?fetchKey,
|
|
31
|
-
|
|
31
|
+
?fetchPolicy,
|
|
32
32
|
?networkCacheConfig,
|
|
33
33
|
},
|
|
34
34
|
)->(RescriptRelay_Internal.internal_useConvertedValue(convertResponse, _))
|
|
@@ -36,7 +36,7 @@ let useQuery = (
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
type useQueryLoaderOptions = {
|
|
39
|
-
fetchPolicy?:
|
|
39
|
+
fetchPolicy?: fetchPolicy,
|
|
40
40
|
networkCacheConfig?: cacheConfig,
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -56,10 +56,7 @@ let useLoader = (
|
|
|
56
56
|
let (nullableQueryRef, loadQueryFn, disposableFn) = useQueryLoader(node)
|
|
57
57
|
let loadQuery = React.useMemo1(
|
|
58
58
|
() => (~variables, ~fetchPolicy=?, ~networkCacheConfig=?, ()) =>
|
|
59
|
-
loadQueryFn(
|
|
60
|
-
variables->convertVariables,
|
|
61
|
-
{fetchPolicy: ?fetchPolicy->mapFetchPolicy, ?networkCacheConfig},
|
|
62
|
-
),
|
|
59
|
+
loadQueryFn(variables->convertVariables, {?fetchPolicy, ?networkCacheConfig}),
|
|
63
60
|
[loadQueryFn],
|
|
64
61
|
)
|
|
65
62
|
(nullableQueryRef->Js.Nullable.toOption->mkQueryRef, loadQuery, disposableFn)
|
|
@@ -117,7 +114,7 @@ let fetch = (
|
|
|
117
114
|
environment,
|
|
118
115
|
node,
|
|
119
116
|
variables->convertVariables,
|
|
120
|
-
Some({networkCacheConfig, fetchPolicy
|
|
117
|
+
Some({?networkCacheConfig, ?fetchPolicy}),
|
|
121
118
|
)
|
|
122
119
|
->subscribe(
|
|
123
120
|
makeObserver(
|
|
@@ -147,7 +144,7 @@ let fetchPromised = (
|
|
|
147
144
|
environment,
|
|
148
145
|
node,
|
|
149
146
|
variables->convertVariables,
|
|
150
|
-
Some({networkCacheConfig, fetchPolicy
|
|
147
|
+
Some({?networkCacheConfig, ?fetchPolicy}),
|
|
151
148
|
)
|
|
152
149
|
->Observable.toPromise
|
|
153
150
|
->Js.Promise2.then(res => res->convertResponse->Js.Promise2.resolve)
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var Curry = require("rescript/lib/js/curry.js");
|
|
5
4
|
var ResolverFragments = require("relay-runtime/lib/store/ResolverFragments");
|
|
6
5
|
|
|
7
6
|
function makeRelayResolver(node, convertFragment, resolver) {
|
|
8
7
|
return function (fRef) {
|
|
9
|
-
return
|
|
8
|
+
return resolver(convertFragment(ResolverFragments.readFragment(node, fRef)));
|
|
10
9
|
};
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var Curry = require("rescript/lib/js/curry.js");
|
|
5
4
|
var RelayRuntime = require("relay-runtime");
|
|
6
5
|
|
|
7
|
-
function subscribe(node, convertVariables, convertResponse
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
function subscribe(node, convertVariables, convertResponse) {
|
|
7
|
+
return function (environment, variables, onCompleted, onError, onNext, updater, param) {
|
|
8
|
+
return RelayRuntime.requestSubscription(environment, {
|
|
9
|
+
subscription: node,
|
|
10
|
+
variables: convertVariables(variables),
|
|
11
|
+
onCompleted: onCompleted,
|
|
12
|
+
onError: onError,
|
|
13
|
+
onNext: onNext !== undefined ? (function (response) {
|
|
14
|
+
onNext(convertResponse(response));
|
|
15
|
+
}) : undefined,
|
|
16
|
+
updater: updater !== undefined ? (function (store, response) {
|
|
17
|
+
updater(store, convertResponse(response));
|
|
18
|
+
}) : undefined
|
|
19
|
+
});
|
|
20
|
+
};
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
exports.subscribe = subscribe;
|