rescript-relay 0.21.0 → 1.0.0-beta.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 +76 -0
- package/README.md +1 -1
- package/bsconfig.json +1 -1
- package/cli/cli.js +4 -4
- package/compiler.js +11 -0
- package/package.json +14 -23
- package/postinstall.js +40 -13
- package/ppx-darwin +0 -0
- package/ppx-linux +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/src/ReactDOMExperimental.bs.js +19 -1
- package/src/ReactDOMExperimental.res +16 -3
- package/src/ReactExperimental.bs.js +1 -16
- package/src/ReactExperimental.res +4 -20
- package/src/RescriptRelay.bs.js +19 -20
- package/src/RescriptRelay.res +30 -26
- package/src/RescriptRelay.resi +24 -34
- package/src/experimental-router/RescriptRelayRouter.bs.js +15 -4
- package/src/experimental-router/RescriptRelayRouter.res +11 -2
- package/src/experimental-router/RescriptRelayRouter.resi +2 -0
- package/src/utils.js +25 -12
- package/bin-darwin +0 -0
- package/bin-linux +0 -0
- package/compiler/compiler-cli.js +0 -54
- package/language-plugin/dist/index.js +0 -1
package/compiler.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var spawn = require("child_process").spawn;
|
|
5
|
+
var path = require("path");
|
|
6
|
+
|
|
7
|
+
var input = process.argv.slice(2);
|
|
8
|
+
|
|
9
|
+
spawn(path.join(__dirname, "rescript-relay-compiler.exe"), input, {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
}).on("exit", process.exit);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rescript-relay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"main": "src/RescriptRelay.res",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gabriel Nordeborn",
|
|
@@ -20,50 +20,41 @@
|
|
|
20
20
|
"rescript"
|
|
21
21
|
],
|
|
22
22
|
"bin": {
|
|
23
|
-
"rescript-relay-compiler": "compiler
|
|
23
|
+
"rescript-relay-compiler": "compiler.js",
|
|
24
24
|
"rescript-relay-cli": "cli/cli.js"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "rescript build -with-deps",
|
|
28
|
-
"build:test": "compiler
|
|
28
|
+
"build:test": "./build-compiler-dev.sh && ./rescript-relay-compiler",
|
|
29
29
|
"postinstall": "node postinstall.js",
|
|
30
30
|
"test": "jest",
|
|
31
31
|
"test:ci": "jest --ci --runInBand"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rescript/react": "0.10.3",
|
|
35
|
-
"@testing-library/jest-dom": "^
|
|
36
|
-
"@testing-library/react": "^
|
|
35
|
+
"@testing-library/jest-dom": "^5.16.1",
|
|
36
|
+
"@testing-library/react": "^13.0.0-alpha.5",
|
|
37
37
|
"bs-fetch": "^0.5.0",
|
|
38
|
-
"graphql": "14.5.0",
|
|
39
38
|
"graphql-query-test-mock": "^0.12.1",
|
|
40
|
-
"jest": "^
|
|
39
|
+
"jest": "^27.2.4",
|
|
41
40
|
"nock": "^11.7.0",
|
|
42
41
|
"node-fetch": "^2.6.0",
|
|
43
|
-
"react": "0.0.0
|
|
44
|
-
"react-dom": "0.0.0
|
|
45
|
-
"react-relay": "
|
|
46
|
-
"
|
|
47
|
-
"relay-compiler": "^11.0.0",
|
|
48
|
-
"relay-config": "^11.0.0",
|
|
49
|
-
"relay-runtime": "^11.0.0"
|
|
42
|
+
"react": "^18.0.0-rc.0",
|
|
43
|
+
"react-dom": "^18.0.0-rc.0",
|
|
44
|
+
"react-relay": "12.0.0",
|
|
45
|
+
"relay-runtime": "12.0.0"
|
|
50
46
|
},
|
|
51
47
|
"peerDependencies": {
|
|
52
48
|
"@rescript/react": "*",
|
|
53
|
-
"graphql": "*",
|
|
54
49
|
"react-relay": "*",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"relay-compiler": "*",
|
|
58
|
-
"relay-config": "*",
|
|
59
|
-
"relay-runtime": "*"
|
|
50
|
+
"relay-runtime": "*",
|
|
51
|
+
"rescript": "^9.1.2"
|
|
60
52
|
},
|
|
61
53
|
"dependencies": {
|
|
62
|
-
"mkdirp-sync": "^0.0.3",
|
|
63
54
|
"rescript": "^9.1.2"
|
|
64
55
|
},
|
|
65
56
|
"resolutions": {
|
|
66
|
-
"react": "0.0.0
|
|
67
|
-
"react-dom": "0.0.0
|
|
57
|
+
"react": "18.0.0-rc.0",
|
|
58
|
+
"react-dom": "18.0.0-rc.0"
|
|
68
59
|
}
|
|
69
60
|
}
|
package/postinstall.js
CHANGED
|
@@ -10,16 +10,27 @@
|
|
|
10
10
|
var path = require("path");
|
|
11
11
|
var cp = require("child_process");
|
|
12
12
|
var fs = require("fs");
|
|
13
|
-
var os = require("os");
|
|
14
13
|
var platform = process.platform;
|
|
15
14
|
|
|
15
|
+
function getRelayCompilerPlatformSuffix() {
|
|
16
|
+
if (process.platform === "darwin" && process.arch === "x64") {
|
|
17
|
+
return "macos-x64";
|
|
18
|
+
} else if (process.platform === "darwin" && process.arch === "arm64") {
|
|
19
|
+
return "macos-arm64";
|
|
20
|
+
} else if (process.platform === "linux" && process.arch === "x64") {
|
|
21
|
+
return "linux-x64";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return "linux-x64";
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
/**
|
|
17
28
|
* Since os.arch returns node binary's target arch, not
|
|
18
29
|
* the system arch.
|
|
19
30
|
* Credits: https://github.com/feross/arch/blob/af080ff61346315559451715c5393d8e86a6d33c/index.js#L10-L58
|
|
20
31
|
*/
|
|
21
32
|
|
|
22
|
-
function
|
|
33
|
+
function ppxArch() {
|
|
23
34
|
/**
|
|
24
35
|
* Use Rosetta for ARM on macOS
|
|
25
36
|
*/
|
|
@@ -80,39 +91,55 @@ function arch() {
|
|
|
80
91
|
}
|
|
81
92
|
|
|
82
93
|
function copyPlatformBinaries(platform) {
|
|
94
|
+
/**
|
|
95
|
+
* Copy the PPX
|
|
96
|
+
*/
|
|
83
97
|
fs.copyFileSync(
|
|
84
98
|
path.join(__dirname, "ppx-" + platform),
|
|
85
99
|
path.join(__dirname, "ppx")
|
|
86
100
|
);
|
|
87
101
|
fs.chmodSync(path.join(__dirname, "ppx"), 0777);
|
|
88
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Copy the Relay compiler
|
|
105
|
+
*/
|
|
106
|
+
|
|
89
107
|
fs.copyFileSync(
|
|
90
|
-
path.join(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
path.join(
|
|
109
|
+
__dirname,
|
|
110
|
+
"relay-compiler-" + getRelayCompilerPlatformSuffix(),
|
|
111
|
+
"relay"
|
|
112
|
+
),
|
|
113
|
+
path.join(__dirname, "rescript-relay-compiler.exe")
|
|
96
114
|
);
|
|
115
|
+
fs.chmodSync(path.join(__dirname, "rescript-relay-compiler.exe"), 0777);
|
|
97
116
|
}
|
|
98
117
|
|
|
99
118
|
function removeInitialBinaries() {
|
|
100
119
|
fs.unlinkSync(path.join(__dirname, "ppx-darwin"));
|
|
101
120
|
fs.unlinkSync(path.join(__dirname, "ppx-linux"));
|
|
102
|
-
fs.
|
|
103
|
-
|
|
121
|
+
fs.rmSync(path.join(__dirname, "relay-compiler-linux-x64"), {
|
|
122
|
+
recursive: true,
|
|
123
|
+
force: true,
|
|
124
|
+
});
|
|
125
|
+
fs.rmSync(path.join(__dirname, "relay-compiler-macos-x64"), {
|
|
126
|
+
recursive: true,
|
|
127
|
+
force: true,
|
|
128
|
+
});
|
|
129
|
+
fs.rmSync(path.join(__dirname, "relay-compiler-macos-arm64"), {
|
|
130
|
+
recursive: true,
|
|
131
|
+
force: true,
|
|
132
|
+
});
|
|
104
133
|
}
|
|
105
134
|
|
|
106
135
|
switch (platform) {
|
|
107
136
|
case "win32": {
|
|
108
|
-
if (
|
|
137
|
+
if (ppxArch() !== "x64") {
|
|
109
138
|
console.warn("error: x86 is currently not supported on Windows");
|
|
110
139
|
process.exit(1);
|
|
111
140
|
}
|
|
112
141
|
|
|
113
142
|
throw new Error("Windows currently not supported.");
|
|
114
|
-
copyPlatformBinaries("windows");
|
|
115
|
-
break;
|
|
116
143
|
}
|
|
117
144
|
case "linux":
|
|
118
145
|
case "darwin":
|
package/ppx-darwin
CHANGED
|
Binary file
|
package/ppx-linux
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var ReactDom = require("react-dom");
|
|
5
|
+
|
|
6
|
+
function renderConcurrentRootAtElementWithId(content, id) {
|
|
7
|
+
var element = document.getElementById(id);
|
|
8
|
+
if (element == null) {
|
|
9
|
+
throw {
|
|
10
|
+
RE_EXN_ID: "Invalid_argument",
|
|
11
|
+
_1: "ReactExperimental.renderConcurrentRootAtElementWithId : no element of id " + id + " found in the HTML.",
|
|
12
|
+
Error: new Error()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
ReactDom.createRoot(element).render(content);
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.renderConcurrentRootAtElementWithId = renderConcurrentRootAtElementWithId;
|
|
20
|
+
/* react-dom Not a pure module */
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
include ReactDOM.Experimental
|
|
2
2
|
|
|
3
3
|
@module("react-dom")
|
|
4
|
-
external
|
|
4
|
+
external createRoot: Dom.element => root = "createRoot"
|
|
5
5
|
|
|
6
|
-
@
|
|
7
|
-
external
|
|
6
|
+
@val @return(nullable)
|
|
7
|
+
external getElementById: string => option<Dom.element> = "document.getElementById"
|
|
8
|
+
|
|
9
|
+
let renderConcurrentRootAtElementWithId: (React.element, string) => unit = (content, id) =>
|
|
10
|
+
switch getElementById(id) {
|
|
11
|
+
| None =>
|
|
12
|
+
raise(
|
|
13
|
+
Invalid_argument(
|
|
14
|
+
"ReactExperimental.renderConcurrentRootAtElementWithId : no element of id " ++
|
|
15
|
+
id ++ " found in the HTML.",
|
|
16
|
+
),
|
|
17
|
+
)
|
|
18
|
+
| Some(element) =>
|
|
19
|
+
createRoot(element)->render(content)
|
|
20
|
+
}
|
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var ReactDom = require("react-dom");
|
|
5
4
|
|
|
6
5
|
var SuspenseList = {};
|
|
7
6
|
|
|
8
|
-
function renderConcurrentRootAtElementWithId(content, id) {
|
|
9
|
-
var element = document.getElementById(id);
|
|
10
|
-
if (element == null) {
|
|
11
|
-
throw {
|
|
12
|
-
RE_EXN_ID: "Invalid_argument",
|
|
13
|
-
_1: "ReactExperimental.renderConcurrentRootAtElementWithId : no element of id " + id + " found in the HTML.",
|
|
14
|
-
Error: new Error()
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
ReactDom.unstable_createRoot(element).render(content);
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
7
|
exports.SuspenseList = SuspenseList;
|
|
22
|
-
|
|
23
|
-
/* react-dom Not a pure module */
|
|
8
|
+
/* No side effect */
|
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
type callback<'input, 'output> = 'input => 'output
|
|
2
2
|
|
|
3
3
|
@module("react")
|
|
4
|
-
external
|
|
4
|
+
external useDeferredValue: 'value => 'value = "useDeferredValue"
|
|
5
5
|
|
|
6
6
|
@module("react")
|
|
7
|
-
external
|
|
8
|
-
"
|
|
7
|
+
external useTransition: unit => (bool, callback<callback<unit, unit>, unit>) =
|
|
8
|
+
"useTransition"
|
|
9
9
|
|
|
10
10
|
module SuspenseList = {
|
|
11
11
|
@module("react") @react.component
|
|
12
12
|
external make: (
|
|
13
13
|
~children: React.element,
|
|
14
14
|
~revealOrder: [#forwards | #backwards | #together]=?,
|
|
15
|
-
) => React.element = "
|
|
15
|
+
) => React.element = "SuspenseList"
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
@val @return(nullable)
|
|
19
|
-
external getElementById: string => option<Dom.element> = "document.getElementById"
|
|
20
|
-
|
|
21
|
-
let renderConcurrentRootAtElementWithId: (React.element, string) => unit = (content, id) =>
|
|
22
|
-
switch getElementById(id) {
|
|
23
|
-
| None =>
|
|
24
|
-
raise(
|
|
25
|
-
Invalid_argument(
|
|
26
|
-
"ReactExperimental.renderConcurrentRootAtElementWithId : no element of id " ++
|
|
27
|
-
id ++ " found in the HTML.",
|
|
28
|
-
),
|
|
29
|
-
)
|
|
30
|
-
| Some(element) =>
|
|
31
|
-
ReactDOMExperimental.unstable_createRoot(element)->ReactDOMExperimental.render(content)
|
|
32
|
-
}
|
package/src/RescriptRelay.bs.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
var Curry = require("rescript/lib/js/curry.js");
|
|
5
5
|
var React = require("react");
|
|
6
6
|
var Utils = require("./utils");
|
|
7
|
-
var $$Promise = require("reason-promise/src/js/promise.bs.js");
|
|
8
7
|
var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
9
8
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
10
9
|
var ReactRelay = require("react-relay");
|
|
@@ -220,25 +219,25 @@ function MakeLoadQuery(C) {
|
|
|
220
219
|
return Caml_option.nullable_to_opt(token.source);
|
|
221
220
|
};
|
|
222
221
|
var queryRefToPromise = function (token) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
222
|
+
return new Promise((function (resolve, param) {
|
|
223
|
+
var o = queryRefToObservable(token);
|
|
224
|
+
if (o !== undefined) {
|
|
225
|
+
Caml_option.valFromOption(o).subscribe({
|
|
226
|
+
complete: (function (param) {
|
|
227
|
+
return resolve({
|
|
228
|
+
TAG: /* Ok */0,
|
|
229
|
+
_0: undefined
|
|
230
|
+
});
|
|
231
|
+
})
|
|
232
|
+
});
|
|
233
|
+
return ;
|
|
234
|
+
} else {
|
|
235
|
+
return resolve({
|
|
236
|
+
TAG: /* Error */1,
|
|
237
|
+
_0: undefined
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}));
|
|
242
241
|
};
|
|
243
242
|
return {
|
|
244
243
|
load: load,
|
package/src/RescriptRelay.res
CHANGED
|
@@ -39,6 +39,8 @@ type featureFlags = {
|
|
|
39
39
|
mutable enableRelayContainersSuspense: bool,
|
|
40
40
|
@as("ENABLE_PRECISE_TYPE_REFINEMENT")
|
|
41
41
|
mutable enablePrecisTypeRefinement: bool,
|
|
42
|
+
@as("ENABLE_REQUIRED_DIRECTIVES")
|
|
43
|
+
mutable enableRequiredDirective: bool,
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
@module("relay-runtime")
|
|
@@ -371,12 +373,16 @@ module MissingFieldHandler = {
|
|
|
371
373
|
}
|
|
372
374
|
|
|
373
375
|
// This handler below enables automatic resolution of all cached items through the Node interface
|
|
374
|
-
let nodeInterfaceMissingFieldHandler = MissingFieldHandler.makeLinkedMissingFieldHandler(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
376
|
+
let nodeInterfaceMissingFieldHandler = MissingFieldHandler.makeLinkedMissingFieldHandler((
|
|
377
|
+
field,
|
|
378
|
+
record,
|
|
379
|
+
args,
|
|
380
|
+
_store,
|
|
381
|
+
) =>
|
|
382
|
+
switch (Js.Nullable.toOption(record), field["name"], Js.Nullable.toOption(args["id"])) {
|
|
383
|
+
| (Some(record), "node", argsId) if record["__typename"] == storeRootType => argsId
|
|
384
|
+
| _ => None
|
|
385
|
+
}
|
|
380
386
|
)
|
|
381
387
|
|
|
382
388
|
module ConnectionHandler = {
|
|
@@ -443,9 +449,9 @@ module Observable = {
|
|
|
443
449
|
}
|
|
444
450
|
|
|
445
451
|
type sink<'response> = {
|
|
446
|
-
next: 'response => unit,
|
|
447
|
-
error: Js.Exn.t => unit,
|
|
448
|
-
complete: unit => unit,
|
|
452
|
+
next: (. 'response) => unit,
|
|
453
|
+
error: (. Js.Exn.t) => unit,
|
|
454
|
+
complete: (. unit) => unit,
|
|
449
455
|
closed: bool,
|
|
450
456
|
}
|
|
451
457
|
|
|
@@ -453,11 +459,11 @@ module Observable = {
|
|
|
453
459
|
|
|
454
460
|
@obj
|
|
455
461
|
external makeObserver: (
|
|
456
|
-
~start: subscription => unit=?,
|
|
457
|
-
~next: 'response => unit=?,
|
|
458
|
-
~error: Js.Exn.t => unit=?,
|
|
459
|
-
~complete: unit => unit=?,
|
|
460
|
-
~unsubscribe: subscription => unit=?,
|
|
462
|
+
~start: @uncurry subscription => unit=?,
|
|
463
|
+
~next: @uncurry 'response => unit=?,
|
|
464
|
+
~error: @uncurry Js.Exn.t => unit=?,
|
|
465
|
+
~complete: @uncurry unit => unit=?,
|
|
466
|
+
~unsubscribe: @uncurry subscription => unit=?,
|
|
461
467
|
unit,
|
|
462
468
|
) => observer<'response> = ""
|
|
463
469
|
|
|
@@ -467,7 +473,7 @@ module Observable = {
|
|
|
467
473
|
@send
|
|
468
474
|
external subscribe: (t<'response>, observer<'response>) => subscription = "subscribe"
|
|
469
475
|
|
|
470
|
-
@send external toPromise: t<'t> => Promise.t<'t> = "toPromise"
|
|
476
|
+
@send external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
|
|
471
477
|
}
|
|
472
478
|
|
|
473
479
|
module Network = {
|
|
@@ -705,18 +711,16 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
|
|
|
705
711
|
}
|
|
706
712
|
|
|
707
713
|
let queryRefToPromise = token => {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
714
|
+
Js.Promise.make((~resolve, ~reject as _) => {
|
|
715
|
+
switch token->queryRefToObservable {
|
|
716
|
+
| None => resolve(. Error())
|
|
717
|
+
| Some(o) =>
|
|
718
|
+
let _: Observable.subscription = o->{
|
|
719
|
+
open Observable
|
|
720
|
+
subscribe(makeObserver(~complete=() => resolve(. Ok()), ()))
|
|
721
|
+
}
|
|
716
722
|
}
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
promise
|
|
723
|
+
})
|
|
720
724
|
}
|
|
721
725
|
}
|
|
722
726
|
|
package/src/RescriptRelay.resi
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
)
|
|
4
4
|
type arguments
|
|
5
5
|
|
|
6
|
-
@ocaml.doc(
|
|
7
|
-
"Abstract type for uploadables.
|
|
6
|
+
@ocaml.doc("Abstract type for uploadables.
|
|
8
7
|
|
|
9
8
|
### Constructing an `uploadables`
|
|
10
9
|
Use `makeUploadable`: `makeUploadable({ \"someFile\": theFileYouWantToUpload })` to construct an `uploadables`, and then pass it to your mutation via the `uploadables` prop.
|
|
11
10
|
|
|
12
|
-
Please note that you'll need to handle _sending_ the uploadables to your server yourself in the network layer. [Here's an example](https://github.com/facebook/relay/issues/1844#issuecomment-316893590) in regular JS that you can adapt to ReScript as you need/want."
|
|
13
|
-
)
|
|
11
|
+
Please note that you'll need to handle _sending_ the uploadables to your server yourself in the network layer. [Here's an example](https://github.com/facebook/relay/issues/1844#issuecomment-316893590) in regular JS that you can adapt to ReScript as you need/want.")
|
|
14
12
|
type uploadables
|
|
15
13
|
|
|
16
14
|
@ocaml.doc(
|
|
@@ -55,12 +53,10 @@ external dataIdToString: dataId => string = "%identity"
|
|
|
55
53
|
@ocaml.doc("Turns a `string` into a `dataId`.")
|
|
56
54
|
external makeDataId: string => dataId = "%identity"
|
|
57
55
|
|
|
58
|
-
@ocaml.doc(
|
|
59
|
-
"Construct an `arguments` object for use with certain Relay store APIs.
|
|
56
|
+
@ocaml.doc("Construct an `arguments` object for use with certain Relay store APIs.
|
|
60
57
|
|
|
61
58
|
### Usage
|
|
62
|
-
Use it like this: `makeArguments({ \"someArgument\": someValue, \"anotherArgument\": anotherValue })`. Notice the \"\" surrounding the property names - these are important and tells ReScript that we want this to be a JS object."
|
|
63
|
-
)
|
|
59
|
+
Use it like this: `makeArguments({ \"someArgument\": someValue, \"anotherArgument\": anotherValue })`. Notice the \"\" surrounding the property names - these are important and tells ReScript that we want this to be a JS object.")
|
|
64
60
|
external makeArguments: {..} => arguments = "%identity"
|
|
65
61
|
|
|
66
62
|
@ocaml.doc(
|
|
@@ -102,6 +98,8 @@ type featureFlags = {
|
|
|
102
98
|
mutable enableRelayContainersSuspense: bool,
|
|
103
99
|
@as("ENABLE_PRECISE_TYPE_REFINEMENT")
|
|
104
100
|
mutable enablePrecisTypeRefinement: bool,
|
|
101
|
+
@as("ENABLE_REQUIRED_DIRECTIVES")
|
|
102
|
+
mutable enableRequiredDirective: bool,
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
@ocaml.doc(
|
|
@@ -110,11 +108,9 @@ type featureFlags = {
|
|
|
110
108
|
@module("relay-runtime")
|
|
111
109
|
external relayFeatureFlags: featureFlags = "RelayFeatureFlags"
|
|
112
110
|
|
|
113
|
-
@ocaml.doc(
|
|
114
|
-
"An abstract type representing all records in the store serialized to JSON in a way that you can use to re-hydrate the store.
|
|
111
|
+
@ocaml.doc("An abstract type representing all records in the store serialized to JSON in a way that you can use to re-hydrate the store.
|
|
115
112
|
|
|
116
|
-
See `RecordSource.toJSON` for how to produce it."
|
|
117
|
-
)
|
|
113
|
+
See `RecordSource.toJSON` for how to produce it.")
|
|
118
114
|
type recordSourceRecords
|
|
119
115
|
|
|
120
116
|
@ocaml.doc(
|
|
@@ -357,13 +353,11 @@ module RecordProxy: {
|
|
|
357
353
|
unit,
|
|
358
354
|
) => t = "setLinkedRecords"
|
|
359
355
|
|
|
360
|
-
@ocaml.doc(
|
|
361
|
-
"Invalidates this record.
|
|
356
|
+
@ocaml.doc("Invalidates this record.
|
|
362
357
|
|
|
363
358
|
Invalidating a record means that the _next_ time Relay evaluates this record, it'll be treated as missing.
|
|
364
359
|
|
|
365
|
-
_Beware_ that this doesn't mean that queries using this record will refetch immediately. Rather, it'll happen the next time the query _renders_. Have a look at `useSubscribeToInvalidationState`, that'll allow you to subscribe to whenever records are invalidated, if you're looking for a way to refetch immediately as something invalidates."
|
|
366
|
-
)
|
|
360
|
+
_Beware_ that this doesn't mean that queries using this record will refetch immediately. Rather, it'll happen the next time the query _renders_. Have a look at `useSubscribeToInvalidationState`, that'll allow you to subscribe to whenever records are invalidated, if you're looking for a way to refetch immediately as something invalidates.")
|
|
367
361
|
@send
|
|
368
362
|
external invalidateRecord: t => unit = "invalidateRecord"
|
|
369
363
|
}
|
|
@@ -426,11 +420,9 @@ module ReadOnlyRecordSourceProxy: {
|
|
|
426
420
|
external getRoot: t => RecordProxy.t = "getRoot"
|
|
427
421
|
}
|
|
428
422
|
|
|
429
|
-
@ocaml.doc(
|
|
430
|
-
"A missing field handler, which is a way of teaching Relay more about the relations in your schema, so it can fulfill more things from the cache. Read more [in this section of the Relay docs](https://relay.dev/docs/guided-tour/reusing-cached-data/filling-in-missing-data/).
|
|
423
|
+
@ocaml.doc("A missing field handler, which is a way of teaching Relay more about the relations in your schema, so it can fulfill more things from the cache. Read more [in this section of the Relay docs](https://relay.dev/docs/guided-tour/reusing-cached-data/filling-in-missing-data/).
|
|
431
424
|
|
|
432
|
-
Feed a list of missing field handlers into `Environment.make` if you want to use them."
|
|
433
|
-
)
|
|
425
|
+
Feed a list of missing field handlers into `Environment.make` if you want to use them.")
|
|
434
426
|
module MissingFieldHandler: {
|
|
435
427
|
@@ocaml.warning("-30")
|
|
436
428
|
|
|
@@ -607,9 +599,9 @@ module Observable: {
|
|
|
607
599
|
|
|
608
600
|
@ocaml.doc("This sink can be used to give the observable new data.")
|
|
609
601
|
type sink<'response> = {
|
|
610
|
-
next: 'response => unit,
|
|
611
|
-
error: Js.Exn.t => unit,
|
|
612
|
-
complete: unit => unit,
|
|
602
|
+
next: (. 'response) => unit,
|
|
603
|
+
error: (. Js.Exn.t) => unit,
|
|
604
|
+
complete: (. unit) => unit,
|
|
613
605
|
closed: bool,
|
|
614
606
|
}
|
|
615
607
|
|
|
@@ -624,10 +616,10 @@ module Observable: {
|
|
|
624
616
|
|
|
625
617
|
@ocaml.doc("Create an observer.") @obj
|
|
626
618
|
external makeObserver: (
|
|
627
|
-
~start: subscription => unit=?,
|
|
628
|
-
~next: 'response => unit=?,
|
|
629
|
-
~error: Js.Exn.t => unit=?,
|
|
630
|
-
~complete: unit => unit=?,
|
|
619
|
+
~start: @uncurry subscription => unit=?,
|
|
620
|
+
~next: @uncurry 'response => unit=?,
|
|
621
|
+
~error: @uncurry Js.Exn.t => unit=?,
|
|
622
|
+
~complete: @uncurry unit => unit=?,
|
|
631
623
|
~unsubscribe: subscription => unit=?,
|
|
632
624
|
unit,
|
|
633
625
|
) => observer<'response> = ""
|
|
@@ -646,7 +638,7 @@ module Observable: {
|
|
|
646
638
|
"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."
|
|
647
639
|
)
|
|
648
640
|
@send
|
|
649
|
-
external toPromise: t<'t> => Promise.t<'t> = "toPromise"
|
|
641
|
+
external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
|
|
650
642
|
}
|
|
651
643
|
|
|
652
644
|
@ocaml.doc("Represents the network layer.")
|
|
@@ -737,7 +729,7 @@ module Store: {
|
|
|
737
729
|
~source: RecordSource.t,
|
|
738
730
|
~gcReleaseBufferSize: /* `gcReleaseBufferSize` controls how many queries are allowed to be cached by default. Increase this to increase the size of the cache. */
|
|
739
731
|
int=?,
|
|
740
|
-
~queryCacheExpirationTime: int /* `queryCacheExpirationTime` sets a TTL (time to live) for all queries. If that time passes, the data is considered stale and is evicted from the store. Default is no TTL.
|
|
732
|
+
~queryCacheExpirationTime: int=? /* `queryCacheExpirationTime` sets a TTL (time to live) for all queries. If that time passes, the data is considered stale and is evicted from the store. Default is no TTL. */,
|
|
741
733
|
unit,
|
|
742
734
|
) => t
|
|
743
735
|
|
|
@@ -790,10 +782,8 @@ module Environment: {
|
|
|
790
782
|
@ocaml.doc("Given an `operationDescriptor`, commits the corresponding payload.") @send
|
|
791
783
|
external commitPayload: (t, operationDescriptor, 'payload) => unit = "commitPayload"
|
|
792
784
|
|
|
793
|
-
@ocaml.doc(
|
|
794
|
-
|
|
795
|
-
You should use the generated `Query.retain` function on your queries instead of using this directly."
|
|
796
|
-
)
|
|
785
|
+
@ocaml.doc("Given an `operationDescriptor`, retains the corresponding operation so any data referenced by it isn't garbage collected.
|
|
786
|
+
You should use the generated `Query.retain` function on your queries instead of using this directly.")
|
|
797
787
|
@send
|
|
798
788
|
external retain: (t, operationDescriptor) => Disposable.t = "retain"
|
|
799
789
|
}
|
|
@@ -897,5 +887,5 @@ module MakeLoadQuery: (C: MakeLoadQueryConfig) =>
|
|
|
897
887
|
) => C.loadedQueryRef
|
|
898
888
|
|
|
899
889
|
let queryRefToObservable: C.loadedQueryRef => option<Observable.t<C.response>>
|
|
900
|
-
let queryRefToPromise: C.loadedQueryRef => Promise.t<Belt.Result.t<unit, unit>>
|
|
890
|
+
let queryRefToPromise: C.loadedQueryRef => Js.Promise.t<Belt.Result.t<unit, unit>>
|
|
901
891
|
}
|
|
@@ -242,8 +242,8 @@ function RescriptRelayRouter$RouteRenderer(Props) {
|
|
|
242
242
|
});
|
|
243
243
|
var initialized = match[0];
|
|
244
244
|
var router = React.useContext(context);
|
|
245
|
-
var match$1 = React.
|
|
246
|
-
var startTransition = match$1[
|
|
245
|
+
var match$1 = React.useTransition();
|
|
246
|
+
var startTransition = match$1[1];
|
|
247
247
|
var match$2 = React.useState(function () {
|
|
248
248
|
return Curry._1(router.get, undefined);
|
|
249
249
|
});
|
|
@@ -281,7 +281,7 @@ function RescriptRelayRouter$RouteRenderer(Props) {
|
|
|
281
281
|
var match$4 = routeEntry.route;
|
|
282
282
|
var renderedContent = initialized && match$4 !== undefined ? Caml_option.some(Curry._1(match$4.render, routeEntry.url)) : undefined;
|
|
283
283
|
if (initialized) {
|
|
284
|
-
return React.createElement(React.Fragment, undefined, renderPending !== undefined ? Curry._1(renderPending, match$1[
|
|
284
|
+
return React.createElement(React.Fragment, undefined, renderPending !== undefined ? Curry._1(renderPending, match$1[0]) : null, React.createElement(React.Suspense, {
|
|
285
285
|
children: renderedContent !== undefined ? Caml_option.valFromOption(renderedContent) : (
|
|
286
286
|
renderNotFound !== undefined ? Curry._1(renderNotFound, routeEntry.url) : null
|
|
287
287
|
),
|
|
@@ -315,10 +315,12 @@ function RescriptRelayRouter$Link(Props) {
|
|
|
315
315
|
var className = Props.className;
|
|
316
316
|
var classNameDynamic = Props.classNameDynamic;
|
|
317
317
|
var browserTarget = Props.target;
|
|
318
|
+
var tabIndex = Props.tabIndex;
|
|
318
319
|
var mode = Props.mode;
|
|
319
320
|
var render = Props.render;
|
|
320
321
|
var preloadOnHover = Props.preloadOnHover;
|
|
321
322
|
var children = Props.children;
|
|
323
|
+
var onClick = Props.onClick;
|
|
322
324
|
var router = React.useContext(context);
|
|
323
325
|
var url = RescriptReactRouter.useUrl(undefined, undefined);
|
|
324
326
|
var changeRoute = React.useCallback((function (e) {
|
|
@@ -369,7 +371,13 @@ function RescriptRelayRouter$Link(Props) {
|
|
|
369
371
|
target: browserTarget !== undefined ? (
|
|
370
372
|
browserTarget === "blank" ? "_blank" : "_self"
|
|
371
373
|
) : "",
|
|
372
|
-
onClick:
|
|
374
|
+
onClick: (function (e) {
|
|
375
|
+
Curry._1(changeRoute, e);
|
|
376
|
+
if (onClick !== undefined) {
|
|
377
|
+
return Curry._1(onClick, undefined);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
}),
|
|
373
381
|
onMouseDown: (function (param) {
|
|
374
382
|
return Curry._1(preload, undefined);
|
|
375
383
|
}),
|
|
@@ -386,6 +394,9 @@ function RescriptRelayRouter$Link(Props) {
|
|
|
386
394
|
if (id !== undefined) {
|
|
387
395
|
tmp.id = Caml_option.valFromOption(id);
|
|
388
396
|
}
|
|
397
|
+
if (tabIndex !== undefined) {
|
|
398
|
+
tmp.tabIndex = Caml_option.valFromOption(tabIndex);
|
|
399
|
+
}
|
|
389
400
|
if (title !== undefined) {
|
|
390
401
|
tmp.title = Caml_option.valFromOption(title);
|
|
391
402
|
}
|