rescript-relay 1.1.1 → 2.0.0-alpha.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 +30 -0
- package/package.json +7 -7
- package/postinstall.js +4 -0
- 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/ReactExperimental.bs.js +5 -3
- package/src/ReactExperimental.res +1 -1
- package/src/ReactExperimental.resi +1 -1
- package/src/RescriptRelay.bs.js +14 -43
- package/src/RescriptRelay.res +23 -37
- package/src/RescriptRelay.resi +35 -24
- package/src/RescriptRelayUtils.bs.js +3 -3
- package/src/RescriptRelay_Fragment.bs.js +115 -0
- package/src/RescriptRelay_Fragment.res +239 -0
- package/src/RescriptRelay_Fragment.resi +86 -0
- package/src/RescriptRelay_Internal.bs.js +2 -3
- package/src/RescriptRelay_Mutation.bs.js +57 -0
- package/src/RescriptRelay_Mutation.res +146 -0
- package/src/RescriptRelay_Mutation.resi +54 -0
- package/src/RescriptRelay_Query.bs.js +101 -0
- package/src/RescriptRelay_Query.res +185 -0
- package/src/RescriptRelay_Query.resi +70 -0
- package/src/RescriptRelay_RelayResolvers.bs.js +13 -0
- package/src/RescriptRelay_RelayResolvers.res +21 -0
- package/src/RescriptRelay_RelayResolvers.resi +10 -0
- package/src/RescriptRelay_Subscriptions.bs.js +24 -0
- package/src/RescriptRelay_Subscriptions.res +51 -0
- package/src/RescriptRelay_Subscriptions.resi +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
+
# 2.0.0-alpha.0
|
|
4
|
+
|
|
5
|
+
First alpha of the `2.x` series of releases. `2.x` focuses on compat with ReScript `v11`, including uncurried mode.
|
|
6
|
+
|
|
7
|
+
## Upgrade versions
|
|
8
|
+
|
|
9
|
+
- `rescript` to `>=11.0.0-beta.0`
|
|
10
|
+
- `@rescript/react` to `>=0.12.0-alpha.2`
|
|
11
|
+
|
|
12
|
+
## Improvements
|
|
13
|
+
|
|
14
|
+
- 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.
|
|
15
|
+
|
|
16
|
+
# 1.2.0
|
|
17
|
+
|
|
18
|
+
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).
|
|
19
|
+
|
|
20
|
+
## Breaking changes
|
|
21
|
+
|
|
22
|
+
- A trailing unit `()` arg is no longer needed in `Query.usePreloaded()`. What was previously `Query.usePreloaded(~queryRef, ())` is now just `Query.usePreloaded(~queryRef)`.
|
|
23
|
+
|
|
24
|
+
## Improvements
|
|
25
|
+
|
|
26
|
+
- Add `@live` annotations to generated JSXv4 dynamic import compat modules, so they don't show up in dead code analysis (which they shouldn't).
|
|
27
|
+
- Preparations under the hood for ReScript v11 + uncurried mode.
|
|
28
|
+
|
|
29
|
+
# 1.1.1
|
|
30
|
+
|
|
31
|
+
- Fix M1 binary to include new JSXv4 dynamic import compat changes.
|
|
32
|
+
|
|
3
33
|
# 1.1.0
|
|
4
34
|
|
|
5
35
|
Notable changes:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rescript-relay",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
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": "^
|
|
43
|
-
"@rescript/react": "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,13 +50,14 @@
|
|
|
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.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/postinstall.js
CHANGED
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
|
|
@@ -3,13 +3,15 @@
|
|
|
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.
|
|
12
|
-
|
|
11
|
+
React.useMemo((function () {
|
|
12
|
+
return function (cb) {
|
|
13
|
+
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.
|
|
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,
|
|
10
|
+
let useTransition: unit => (bool, (unit => unit) => unit)
|
|
11
11
|
|
|
12
12
|
module SuspenseList: {
|
|
13
13
|
@module("react") @react.component
|
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");
|
|
@@ -50,22 +49,22 @@ function unwrapNormalizationArgument(wrapped) {
|
|
|
50
49
|
var match = wrapped.kind;
|
|
51
50
|
if (match === "Literal") {
|
|
52
51
|
return {
|
|
53
|
-
TAG:
|
|
52
|
+
TAG: "Literal",
|
|
54
53
|
_0: wrapped
|
|
55
54
|
};
|
|
56
55
|
} else if (match === "ListValue") {
|
|
57
56
|
return {
|
|
58
|
-
TAG:
|
|
57
|
+
TAG: "ListValue",
|
|
59
58
|
_0: wrapped
|
|
60
59
|
};
|
|
61
60
|
} else if (match === "ObjectValue") {
|
|
62
61
|
return {
|
|
63
|
-
TAG:
|
|
62
|
+
TAG: "ObjectValue",
|
|
64
63
|
_0: wrapped
|
|
65
64
|
};
|
|
66
65
|
} else {
|
|
67
66
|
return {
|
|
68
|
-
TAG:
|
|
67
|
+
TAG: "Variable",
|
|
69
68
|
_0: wrapped
|
|
70
69
|
};
|
|
71
70
|
}
|
|
@@ -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 */0 :
|
|
200
|
-
return "store-only";
|
|
201
|
-
case /* StoreOrNetwork */1 :
|
|
202
|
-
return "store-or-network";
|
|
203
|
-
case /* StoreAndNetwork */2 :
|
|
204
|
-
return "store-and-network";
|
|
205
|
-
case /* NetworkOnly */3 :
|
|
206
|
-
return "network-only";
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function mapFetchQueryFetchPolicy(x) {
|
|
212
|
-
if (x !== undefined) {
|
|
213
|
-
if (x) {
|
|
214
|
-
return "store-or-network";
|
|
215
|
-
} else {
|
|
216
|
-
return "network-only";
|
|
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,9 +208,9 @@ 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
|
-
TAG:
|
|
213
|
+
TAG: "Ok",
|
|
241
214
|
_0: undefined
|
|
242
215
|
});
|
|
243
216
|
})
|
|
@@ -245,7 +218,7 @@ function MakeLoadQuery(C) {
|
|
|
245
218
|
return ;
|
|
246
219
|
} else {
|
|
247
220
|
return resolve({
|
|
248
|
-
TAG:
|
|
221
|
+
TAG: "Error",
|
|
249
222
|
_0: undefined
|
|
250
223
|
});
|
|
251
224
|
}
|
|
@@ -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
|
|
|
@@ -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 =
|
|
598
|
+
let toJs: t => js = f => arg =>
|
|
597
599
|
f(~kind=arg["kind"], ~owner=arg["owner"], ~fieldPath=arg["fieldPath"])
|
|
598
600
|
}
|
|
599
601
|
|
|
@@ -679,39 +681,23 @@ let useEnvironmentFromContext = () => {
|
|
|
679
681
|
}
|
|
680
682
|
|
|
681
683
|
type fetchPolicy =
|
|
682
|
-
| StoreOnly
|
|
683
|
-
| StoreOrNetwork
|
|
684
|
-
| StoreAndNetwork
|
|
685
|
-
| NetworkOnly
|
|
686
|
-
|
|
687
|
-
let mapFetchPolicy = x =>
|
|
688
|
-
switch x {
|
|
689
|
-
| Some(StoreOnly) => Some("store-only")
|
|
690
|
-
| Some(StoreOrNetwork) => Some("store-or-network")
|
|
691
|
-
| Some(StoreAndNetwork) => Some("store-and-network")
|
|
692
|
-
| Some(NetworkOnly) => Some("network-only")
|
|
693
|
-
| None => None
|
|
694
|
-
}
|
|
684
|
+
| @as("store-only") StoreOnly
|
|
685
|
+
| @as("store-or-network") StoreOrNetwork
|
|
686
|
+
| @as("store-and-network") StoreAndNetwork
|
|
687
|
+
| @as("network-only") NetworkOnly
|
|
695
688
|
|
|
696
689
|
type fetchQueryFetchPolicy =
|
|
697
|
-
| NetworkOnly
|
|
698
|
-
| StoreOrNetwork
|
|
699
|
-
|
|
700
|
-
let mapFetchQueryFetchPolicy = x =>
|
|
701
|
-
switch x {
|
|
702
|
-
| Some(StoreOrNetwork) => Some("store-or-network")
|
|
703
|
-
| Some(NetworkOnly) => Some("network-only")
|
|
704
|
-
| None => None
|
|
705
|
-
}
|
|
690
|
+
| @as("network-only") NetworkOnly
|
|
691
|
+
| @as("store-or-network") StoreOrNetwork
|
|
706
692
|
|
|
707
693
|
type fetchQueryOptions = {
|
|
708
|
-
networkCacheConfig
|
|
709
|
-
fetchPolicy
|
|
694
|
+
networkCacheConfig?: cacheConfig,
|
|
695
|
+
fetchPolicy?: fetchPolicy,
|
|
710
696
|
}
|
|
711
697
|
|
|
712
698
|
type loadQueryConfig = {
|
|
713
699
|
fetchKey: option<string>,
|
|
714
|
-
fetchPolicy: option<
|
|
700
|
+
fetchPolicy: option<fetchPolicy>,
|
|
715
701
|
networkCacheConfig: option<cacheConfig>,
|
|
716
702
|
}
|
|
717
703
|
|
|
@@ -750,7 +736,7 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
|
|
|
750
736
|
variables->C.convertVariables,
|
|
751
737
|
{
|
|
752
738
|
fetchKey,
|
|
753
|
-
fetchPolicy
|
|
739
|
+
fetchPolicy,
|
|
754
740
|
networkCacheConfig,
|
|
755
741
|
},
|
|
756
742
|
)
|
|
@@ -766,10 +752,10 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
|
|
|
766
752
|
let queryRefToPromise = token => {
|
|
767
753
|
Js.Promise.make((~resolve, ~reject as _) => {
|
|
768
754
|
switch token->queryRefToObservable {
|
|
769
|
-
| None => resolve(
|
|
755
|
+
| None => resolve(Error())
|
|
770
756
|
| Some(o) =>
|
|
771
757
|
open Observable
|
|
772
|
-
let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(
|
|
758
|
+
let _: subscription = o->subscribe(makeObserver(~complete=() => resolve(Ok()), ()))
|
|
773
759
|
}
|
|
774
760
|
})
|
|
775
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> = ""
|
|
@@ -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.*/
|
|
@@ -769,21 +771,27 @@ You should use the generated `Query.retain` function on your queries instead of
|
|
|
769
771
|
|
|
770
772
|
/**fetchPolicy controls how you want Relay to resolve your data.*/
|
|
771
773
|
type fetchPolicy =
|
|
772
|
-
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
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
|
|
779
786
|
|
|
780
787
|
/**The fetch policies allowed for fetching a query outside of React's render (as in `Query.fetch`).*/
|
|
781
788
|
type fetchQueryFetchPolicy =
|
|
782
|
-
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
|
|
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
|
|
787
795
|
|
|
788
796
|
/**An error from a mutation.*/
|
|
789
797
|
type mutationError = {message: string}
|
|
@@ -803,8 +811,11 @@ module Context: {
|
|
|
803
811
|
/**The context provider you wrap your app in and pass your `Environment` for Relay to work.*/
|
|
804
812
|
module Provider: {
|
|
805
813
|
/**The React component you wrap your app in and pass your `Environment` for Relay to work.*/
|
|
806
|
-
|
|
807
|
-
|
|
814
|
+
type props<'environment, 'children> = {
|
|
815
|
+
environment: 'environment,
|
|
816
|
+
children: 'children,
|
|
817
|
+
}
|
|
818
|
+
let make: props<Environment.t, React.element> => React.element
|
|
808
819
|
}
|
|
809
820
|
}
|
|
810
821
|
|
|
@@ -830,8 +841,8 @@ external useSubscribeToInvalidationState: (array<dataId>, unit => unit) => Dispo
|
|
|
830
841
|
|
|
831
842
|
/**Options valid when fetching a query outside of React's render method (like when using `Query.fetch`).*/
|
|
832
843
|
type fetchQueryOptions = {
|
|
833
|
-
networkCacheConfig
|
|
834
|
-
fetchPolicy
|
|
844
|
+
networkCacheConfig?: cacheConfig,
|
|
845
|
+
fetchPolicy?: fetchPolicy,
|
|
835
846
|
}
|
|
836
847
|
|
|
837
848
|
module type MakeLoadQueryConfig = {
|
|
@@ -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,115 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require("react");
|
|
5
|
+
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
6
|
+
var ReactRelay = require("react-relay");
|
|
7
|
+
var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
|
|
8
|
+
|
|
9
|
+
function useFragment(node, convertFragment, fRef) {
|
|
10
|
+
var __x = ReactRelay.useFragment(node, fRef);
|
|
11
|
+
return RescriptRelay_Internal.internal_useConvertedValue(convertFragment, __x);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function useFragmentOpt(fRef, node, convertFragment) {
|
|
15
|
+
var data = ReactRelay.useFragment(node, fRef);
|
|
16
|
+
return React.useMemo((function () {
|
|
17
|
+
if (!(data == null)) {
|
|
18
|
+
return Caml_option.some(convertFragment(data));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}), [(data == null) ? undefined : Caml_option.some(data)]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function readInlineData(node, convertFragment, fRef) {
|
|
25
|
+
return convertFragment(ReactRelay.readInlineData(node, fRef));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function internal_makeRefetchableFnOpts(fetchPolicy, onComplete, param) {
|
|
29
|
+
return {
|
|
30
|
+
fetchPolicy: fetchPolicy,
|
|
31
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function usePaginationFragment(node, fRef, convertFragment, convertRefetchVariables) {
|
|
36
|
+
var p = ReactRelay.usePaginationFragment(node, fRef);
|
|
37
|
+
var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
|
|
38
|
+
return {
|
|
39
|
+
data: data,
|
|
40
|
+
loadNext: React.useMemo((function () {
|
|
41
|
+
return function (count, onComplete, param) {
|
|
42
|
+
return p.loadNext(count, {
|
|
43
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}), [p.loadNext]),
|
|
47
|
+
loadPrevious: React.useMemo((function () {
|
|
48
|
+
return function (count, onComplete, param) {
|
|
49
|
+
return p.loadPrevious(count, {
|
|
50
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
}), [p.loadPrevious]),
|
|
54
|
+
hasNext: p.hasNext,
|
|
55
|
+
hasPrevious: p.hasPrevious,
|
|
56
|
+
isLoadingNext: p.isLoadingNext,
|
|
57
|
+
isLoadingPrevious: p.isLoadingPrevious,
|
|
58
|
+
refetch: React.useMemo((function () {
|
|
59
|
+
return function (variables, fetchPolicy, onComplete, param) {
|
|
60
|
+
return p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
61
|
+
};
|
|
62
|
+
}), [p.refetch])
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function useBlockingPaginationFragment(node, fRef, convertFragment, convertRefetchVariables) {
|
|
67
|
+
var p = ReactRelay.useBlockingPaginationFragment(node, fRef);
|
|
68
|
+
var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, p.data);
|
|
69
|
+
return {
|
|
70
|
+
data: data,
|
|
71
|
+
loadNext: React.useMemo((function () {
|
|
72
|
+
return function (count, onComplete, param) {
|
|
73
|
+
return p.loadNext(count, {
|
|
74
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}), [p.loadNext]),
|
|
78
|
+
loadPrevious: React.useMemo((function () {
|
|
79
|
+
return function (count, onComplete, param) {
|
|
80
|
+
return p.loadPrevious(count, {
|
|
81
|
+
onComplete: RescriptRelay_Internal.internal_nullableToOptionalExnHandler(onComplete)
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
}), [p.loadPrevious]),
|
|
85
|
+
hasNext: p.hasNext,
|
|
86
|
+
hasPrevious: p.hasPrevious,
|
|
87
|
+
refetch: React.useMemo((function () {
|
|
88
|
+
return function (variables, fetchPolicy, onComplete, param) {
|
|
89
|
+
return p.refetch(RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
90
|
+
};
|
|
91
|
+
}), [p.refetch])
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function useRefetchableFragment(node, convertFragment, convertRefetchVariables, fRef) {
|
|
96
|
+
var match = ReactRelay.useRefetchableFragment(node, fRef);
|
|
97
|
+
var refetchFn = match[1];
|
|
98
|
+
var data = RescriptRelay_Internal.internal_useConvertedValue(convertFragment, match[0]);
|
|
99
|
+
return [
|
|
100
|
+
data,
|
|
101
|
+
React.useMemo((function () {
|
|
102
|
+
return function (variables, fetchPolicy, onComplete, param) {
|
|
103
|
+
return refetchFn(RescriptRelay_Internal.internal_removeUndefinedAndConvertNullsRaw(convertRefetchVariables(variables)), internal_makeRefetchableFnOpts(fetchPolicy, onComplete, undefined));
|
|
104
|
+
};
|
|
105
|
+
}), [refetchFn])
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
exports.useFragment = useFragment;
|
|
110
|
+
exports.useFragmentOpt = useFragmentOpt;
|
|
111
|
+
exports.readInlineData = readInlineData;
|
|
112
|
+
exports.usePaginationFragment = usePaginationFragment;
|
|
113
|
+
exports.useBlockingPaginationFragment = useBlockingPaginationFragment;
|
|
114
|
+
exports.useRefetchableFragment = useRefetchableFragment;
|
|
115
|
+
/* react Not a pure module */
|