rescript-relay 0.0.0-cli-687699fd → 0.0.0-linux-musl-d5435e23
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 +141 -0
- package/README.md +7 -11
- package/bsconfig.json +1 -1
- package/cli/cli.js +29 -35
- package/compiler.js +11 -0
- package/package.json +23 -23
- package/postinstall.js +43 -13
- package/ppx-darwin +0 -0
- package/ppx-linux +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/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 +32 -21
- package/src/RescriptRelay.res +76 -31
- package/src/RescriptRelay.resi +66 -39
- 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 +182 -190
- package/src/utils.mjs +339 -0
- 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.0.0-
|
|
3
|
+
"version": "0.0.0-linux-musl-d5435e23",
|
|
4
4
|
"main": "src/RescriptRelay.res",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gabriel Nordeborn",
|
|
@@ -19,51 +19,51 @@
|
|
|
19
19
|
"reasonml",
|
|
20
20
|
"rescript"
|
|
21
21
|
],
|
|
22
|
+
"exports": {
|
|
23
|
+
"./src/utils": {
|
|
24
|
+
"require": "./src/utils.js",
|
|
25
|
+
"import": "./src/utils.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./src/*": "./src/*",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
22
30
|
"bin": {
|
|
23
|
-
"rescript-relay-compiler": "compiler
|
|
31
|
+
"rescript-relay-compiler": "compiler.js",
|
|
24
32
|
"rescript-relay-cli": "cli/cli.js"
|
|
25
33
|
},
|
|
26
34
|
"scripts": {
|
|
27
35
|
"build": "rescript build -with-deps",
|
|
28
|
-
"build:test": "compiler
|
|
36
|
+
"build:test": "./build-compiler-dev.sh && ./rescript-relay-compiler",
|
|
29
37
|
"postinstall": "node postinstall.js",
|
|
30
38
|
"test": "jest",
|
|
31
39
|
"test:ci": "jest --ci --runInBand"
|
|
32
40
|
},
|
|
33
41
|
"devDependencies": {
|
|
34
42
|
"@rescript/react": "0.10.3",
|
|
35
|
-
"@testing-library/jest-dom": "^
|
|
36
|
-
"@testing-library/react": "^
|
|
43
|
+
"@testing-library/jest-dom": "^5.16.1",
|
|
44
|
+
"@testing-library/react": "^13.0.0-alpha.5",
|
|
37
45
|
"bs-fetch": "^0.5.0",
|
|
38
|
-
"graphql": "14.5.0",
|
|
39
46
|
"graphql-query-test-mock": "^0.12.1",
|
|
40
|
-
"jest": "^
|
|
47
|
+
"jest": "^27.2.4",
|
|
41
48
|
"nock": "^11.7.0",
|
|
42
49
|
"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"
|
|
50
|
+
"react": "^18.0.0-rc.0",
|
|
51
|
+
"react-dom": "^18.0.0-rc.0",
|
|
52
|
+
"react-relay": "13.1.1",
|
|
53
|
+
"relay-runtime": "13.1.1"
|
|
50
54
|
},
|
|
51
55
|
"peerDependencies": {
|
|
52
56
|
"@rescript/react": "*",
|
|
53
|
-
"graphql": "*",
|
|
54
57
|
"react-relay": "*",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"relay-compiler": "*",
|
|
58
|
-
"relay-config": "*",
|
|
59
|
-
"relay-runtime": "*"
|
|
58
|
+
"relay-runtime": "*",
|
|
59
|
+
"rescript": "^9.1.2"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"
|
|
62
|
+
"detect-libc": "^2.0.1",
|
|
63
63
|
"rescript": "^9.1.2"
|
|
64
64
|
},
|
|
65
65
|
"resolutions": {
|
|
66
|
-
"react": "0.0.0
|
|
67
|
-
"react-dom": "0.0.0
|
|
66
|
+
"react": "18.0.0-rc.0",
|
|
67
|
+
"react-dom": "18.0.0-rc.0"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/postinstall.js
CHANGED
|
@@ -10,16 +10,30 @@
|
|
|
10
10
|
var path = require("path");
|
|
11
11
|
var cp = require("child_process");
|
|
12
12
|
var fs = require("fs");
|
|
13
|
-
var
|
|
13
|
+
var { isNonGlibcLinux } = require("detect-libc");
|
|
14
14
|
var platform = process.platform;
|
|
15
15
|
|
|
16
|
+
function getRelayCompilerPlatformSuffix() {
|
|
17
|
+
if (process.platform === "darwin" && process.arch === "x64") {
|
|
18
|
+
return "macos-x64";
|
|
19
|
+
} else if (process.platform === "darwin" && process.arch === "arm64") {
|
|
20
|
+
return "macos-arm64";
|
|
21
|
+
} else if (process.platform === "linux" && isNonGlibcLinux) {
|
|
22
|
+
return "linux-musl";
|
|
23
|
+
} else if (process.platform === "linux" && process.arch === "x64") {
|
|
24
|
+
return "linux-x64";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return "linux-x64";
|
|
28
|
+
}
|
|
29
|
+
|
|
16
30
|
/**
|
|
17
31
|
* Since os.arch returns node binary's target arch, not
|
|
18
32
|
* the system arch.
|
|
19
33
|
* Credits: https://github.com/feross/arch/blob/af080ff61346315559451715c5393d8e86a6d33c/index.js#L10-L58
|
|
20
34
|
*/
|
|
21
35
|
|
|
22
|
-
function
|
|
36
|
+
function ppxArch() {
|
|
23
37
|
/**
|
|
24
38
|
* Use Rosetta for ARM on macOS
|
|
25
39
|
*/
|
|
@@ -80,39 +94,55 @@ function arch() {
|
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
function copyPlatformBinaries(platform) {
|
|
97
|
+
/**
|
|
98
|
+
* Copy the PPX
|
|
99
|
+
*/
|
|
83
100
|
fs.copyFileSync(
|
|
84
101
|
path.join(__dirname, "ppx-" + platform),
|
|
85
102
|
path.join(__dirname, "ppx")
|
|
86
103
|
);
|
|
87
104
|
fs.chmodSync(path.join(__dirname, "ppx"), 0777);
|
|
88
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Copy the Relay compiler
|
|
108
|
+
*/
|
|
109
|
+
|
|
89
110
|
fs.copyFileSync(
|
|
90
|
-
path.join(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
111
|
+
path.join(
|
|
112
|
+
__dirname,
|
|
113
|
+
"relay-compiler-" + getRelayCompilerPlatformSuffix(),
|
|
114
|
+
"relay"
|
|
115
|
+
),
|
|
116
|
+
path.join(__dirname, "rescript-relay-compiler.exe")
|
|
96
117
|
);
|
|
118
|
+
fs.chmodSync(path.join(__dirname, "rescript-relay-compiler.exe"), 0777);
|
|
97
119
|
}
|
|
98
120
|
|
|
99
121
|
function removeInitialBinaries() {
|
|
100
122
|
fs.unlinkSync(path.join(__dirname, "ppx-darwin"));
|
|
101
123
|
fs.unlinkSync(path.join(__dirname, "ppx-linux"));
|
|
102
|
-
fs.
|
|
103
|
-
|
|
124
|
+
fs.rmSync(path.join(__dirname, "relay-compiler-linux-x64"), {
|
|
125
|
+
recursive: true,
|
|
126
|
+
force: true,
|
|
127
|
+
});
|
|
128
|
+
fs.rmSync(path.join(__dirname, "relay-compiler-macos-x64"), {
|
|
129
|
+
recursive: true,
|
|
130
|
+
force: true,
|
|
131
|
+
});
|
|
132
|
+
fs.rmSync(path.join(__dirname, "relay-compiler-macos-arm64"), {
|
|
133
|
+
recursive: true,
|
|
134
|
+
force: true,
|
|
135
|
+
});
|
|
104
136
|
}
|
|
105
137
|
|
|
106
138
|
switch (platform) {
|
|
107
139
|
case "win32": {
|
|
108
|
-
if (
|
|
140
|
+
if (ppxArch() !== "x64") {
|
|
109
141
|
console.warn("error: x86 is currently not supported on Windows");
|
|
110
142
|
process.exit(1);
|
|
111
143
|
}
|
|
112
144
|
|
|
113
145
|
throw new Error("Windows currently not supported.");
|
|
114
|
-
copyPlatformBinaries("windows");
|
|
115
|
-
break;
|
|
116
146
|
}
|
|
117
147
|
case "linux":
|
|
118
148
|
case "darwin":
|
package/ppx-darwin
CHANGED
|
Binary file
|
package/ppx-linux
CHANGED
|
Binary file
|
|
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,8 +4,8 @@
|
|
|
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");
|
|
8
|
+
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
9
9
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
10
10
|
var ReactRelay = require("react-relay");
|
|
11
11
|
var RelayRuntime = require("relay-runtime");
|
|
@@ -131,7 +131,11 @@ var Store = {
|
|
|
131
131
|
make: make
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
function
|
|
134
|
+
function toJs(f, arg) {
|
|
135
|
+
return Curry._3(f, arg.kind, arg.owner, arg.fieldPath);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFieldHandlers, requiredFieldLogger, param) {
|
|
135
139
|
var tmp = {
|
|
136
140
|
network: network,
|
|
137
141
|
store: store,
|
|
@@ -143,6 +147,10 @@ function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFiel
|
|
|
143
147
|
if (treatMissingFieldsAsNull !== undefined) {
|
|
144
148
|
tmp.treatMissingFieldsAsNull = Caml_option.valFromOption(treatMissingFieldsAsNull);
|
|
145
149
|
}
|
|
150
|
+
var tmp$1 = Belt_Option.map(requiredFieldLogger, toJs);
|
|
151
|
+
if (tmp$1 !== undefined) {
|
|
152
|
+
tmp.requiredFieldLogger = Caml_option.valFromOption(tmp$1);
|
|
153
|
+
}
|
|
146
154
|
return new RelayRuntime.Environment(tmp);
|
|
147
155
|
}
|
|
148
156
|
|
|
@@ -220,25 +228,25 @@ function MakeLoadQuery(C) {
|
|
|
220
228
|
return Caml_option.nullable_to_opt(token.source);
|
|
221
229
|
};
|
|
222
230
|
var queryRefToPromise = function (token) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
231
|
+
return new Promise((function (resolve, param) {
|
|
232
|
+
var o = queryRefToObservable(token);
|
|
233
|
+
if (o !== undefined) {
|
|
234
|
+
Caml_option.valFromOption(o).subscribe({
|
|
235
|
+
complete: (function (param) {
|
|
236
|
+
return resolve({
|
|
237
|
+
TAG: /* Ok */0,
|
|
238
|
+
_0: undefined
|
|
239
|
+
});
|
|
240
|
+
})
|
|
241
|
+
});
|
|
242
|
+
return ;
|
|
243
|
+
} else {
|
|
244
|
+
return resolve({
|
|
245
|
+
TAG: /* Error */1,
|
|
246
|
+
_0: undefined
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}));
|
|
242
250
|
};
|
|
243
251
|
return {
|
|
244
252
|
load: load,
|
|
@@ -249,6 +257,8 @@ function MakeLoadQuery(C) {
|
|
|
249
257
|
|
|
250
258
|
var Mutation_failed = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.Mutation_failed");
|
|
251
259
|
|
|
260
|
+
var RequiredFieldLogger = {};
|
|
261
|
+
|
|
252
262
|
var Context = {
|
|
253
263
|
Provider: Provider
|
|
254
264
|
};
|
|
@@ -264,6 +274,7 @@ exports.Network = Network;
|
|
|
264
274
|
exports.RecordSource = RecordSource;
|
|
265
275
|
exports.Store = Store;
|
|
266
276
|
exports.Disposable = Disposable;
|
|
277
|
+
exports.RequiredFieldLogger = RequiredFieldLogger;
|
|
267
278
|
exports.Environment = Environment;
|
|
268
279
|
exports.mapFetchPolicy = mapFetchPolicy;
|
|
269
280
|
exports.mapFetchQueryFetchPolicy = mapFetchQueryFetchPolicy;
|
package/src/RescriptRelay.res
CHANGED
|
@@ -11,7 +11,7 @@ type subscriptionNode<'node>
|
|
|
11
11
|
type fragmentRefs<'fragments>
|
|
12
12
|
|
|
13
13
|
type dataId
|
|
14
|
-
type recordSourceRecords
|
|
14
|
+
type recordSourceRecords = Js.Json.t
|
|
15
15
|
type uploadables
|
|
16
16
|
|
|
17
17
|
external dataIdToString: dataId => string = "%identity"
|
|
@@ -31,14 +31,40 @@ external generateUniqueClientID: unit => dataId = "generateUniqueClientID"
|
|
|
31
31
|
external isClientID: dataId => bool = "isClientID"
|
|
32
32
|
|
|
33
33
|
type featureFlags = {
|
|
34
|
+
@as("DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES")
|
|
35
|
+
mutable delayCleanupOfPendingPreloadQueries: bool,
|
|
36
|
+
@as("ENABLE_CLIENT_EDGES")
|
|
37
|
+
mutable enableClientEdges: bool,
|
|
34
38
|
@as("ENABLE_VARIABLE_CONNECTION_KEY")
|
|
35
39
|
mutable enableVariableConnectionKey: bool,
|
|
36
40
|
@as("ENABLE_PARTIAL_RENDERING_DEFAULT")
|
|
37
41
|
mutable enablePartialRenderingDefault: bool,
|
|
38
|
-
@as("
|
|
39
|
-
mutable
|
|
40
|
-
@as("
|
|
41
|
-
mutable
|
|
42
|
+
@as("ENABLE_REACT_FLIGHT_COMPONENT_FIELD")
|
|
43
|
+
mutable enableReactFlightComponentField: bool,
|
|
44
|
+
@as("ENABLE_RELAY_RESOLVERS")
|
|
45
|
+
mutable enableRelayResolvers: bool,
|
|
46
|
+
@as("ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION")
|
|
47
|
+
mutable enableGetFragmentIdentifierOptimization: bool,
|
|
48
|
+
@as("ENABLE_FRIENDLY_QUERY_NAME_GQL_URL")
|
|
49
|
+
mutable enableFriendlyQueryNameGqlUrl: bool,
|
|
50
|
+
@as("ENABLE_LOAD_QUERY_REQUEST_DEDUPING")
|
|
51
|
+
mutable enableLoadQueryRequestDeduping: bool,
|
|
52
|
+
@as("ENABLE_DO_NOT_WRAP_LIVE_QUERY")
|
|
53
|
+
mutable enableDoNotWrapLiveQuery: bool,
|
|
54
|
+
@as("ENABLE_NOTIFY_SUBSCRIPTION")
|
|
55
|
+
mutable enableNotifySubscription: bool,
|
|
56
|
+
@as("ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT")
|
|
57
|
+
mutable enableContainersSubscribeOnCommit: bool,
|
|
58
|
+
@as("ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT")
|
|
59
|
+
mutable enableQueryRendererOffscreenSupport: bool,
|
|
60
|
+
@as("MAX_DATA_ID_LENGTH")
|
|
61
|
+
mutable maxDataIdLength: option<int>,
|
|
62
|
+
@as("REFACTOR_SUSPENSE_RESOURCE")
|
|
63
|
+
mutable refactorSuspenseResource: bool,
|
|
64
|
+
@as("STRING_INTERN_LEVEL")
|
|
65
|
+
mutable stringInternLevel: int,
|
|
66
|
+
@as("USE_REACT_CACHE")
|
|
67
|
+
mutable useReactCache: bool,
|
|
42
68
|
}
|
|
43
69
|
|
|
44
70
|
@module("relay-runtime")
|
|
@@ -371,12 +397,16 @@ module MissingFieldHandler = {
|
|
|
371
397
|
}
|
|
372
398
|
|
|
373
399
|
// This handler below enables automatic resolution of all cached items through the Node interface
|
|
374
|
-
let nodeInterfaceMissingFieldHandler = MissingFieldHandler.makeLinkedMissingFieldHandler(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
400
|
+
let nodeInterfaceMissingFieldHandler = MissingFieldHandler.makeLinkedMissingFieldHandler((
|
|
401
|
+
field,
|
|
402
|
+
record,
|
|
403
|
+
args,
|
|
404
|
+
_store,
|
|
405
|
+
) =>
|
|
406
|
+
switch (Js.Nullable.toOption(record), field["name"], Js.Nullable.toOption(args["id"])) {
|
|
407
|
+
| (Some(record), "node", argsId) if record["__typename"] == storeRootType => argsId
|
|
408
|
+
| _ => None
|
|
409
|
+
}
|
|
380
410
|
)
|
|
381
411
|
|
|
382
412
|
module ConnectionHandler = {
|
|
@@ -443,9 +473,9 @@ module Observable = {
|
|
|
443
473
|
}
|
|
444
474
|
|
|
445
475
|
type sink<'response> = {
|
|
446
|
-
next: 'response => unit,
|
|
447
|
-
error: Js.Exn.t => unit,
|
|
448
|
-
complete: unit => unit,
|
|
476
|
+
next: (. 'response) => unit,
|
|
477
|
+
error: (. Js.Exn.t) => unit,
|
|
478
|
+
complete: (. unit) => unit,
|
|
449
479
|
closed: bool,
|
|
450
480
|
}
|
|
451
481
|
|
|
@@ -453,11 +483,11 @@ module Observable = {
|
|
|
453
483
|
|
|
454
484
|
@obj
|
|
455
485
|
external makeObserver: (
|
|
456
|
-
~start: subscription => unit=?,
|
|
457
|
-
~next: 'response => unit=?,
|
|
458
|
-
~error: Js.Exn.t => unit=?,
|
|
459
|
-
~complete: unit => unit=?,
|
|
460
|
-
~unsubscribe: subscription => unit=?,
|
|
486
|
+
~start: @uncurry subscription => unit=?,
|
|
487
|
+
~next: @uncurry 'response => unit=?,
|
|
488
|
+
~error: @uncurry Js.Exn.t => unit=?,
|
|
489
|
+
~complete: @uncurry unit => unit=?,
|
|
490
|
+
~unsubscribe: @uncurry subscription => unit=?,
|
|
461
491
|
unit,
|
|
462
492
|
) => observer<'response> = ""
|
|
463
493
|
|
|
@@ -467,7 +497,7 @@ module Observable = {
|
|
|
467
497
|
@send
|
|
468
498
|
external subscribe: (t<'response>, observer<'response>) => subscription = "subscribe"
|
|
469
499
|
|
|
470
|
-
@send external toPromise: t<'t> => Promise.t<'t> = "toPromise"
|
|
500
|
+
@send external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
|
|
471
501
|
}
|
|
472
502
|
|
|
473
503
|
module Network = {
|
|
@@ -544,6 +574,19 @@ module Store = {
|
|
|
544
574
|
@send external publish: (t, RecordSource.t) => unit = "publish"
|
|
545
575
|
}
|
|
546
576
|
|
|
577
|
+
module RequiredFieldLogger = {
|
|
578
|
+
type kind = [#"missing_field.log" | #"missing_field.throw"]
|
|
579
|
+
|
|
580
|
+
type arg = {"kind": kind, "owner": string, "fieldPath": string}
|
|
581
|
+
|
|
582
|
+
type js = arg => unit
|
|
583
|
+
|
|
584
|
+
type t = (~kind: kind, ~owner: string, ~fieldPath: string) => unit
|
|
585
|
+
|
|
586
|
+
let toJs: t => js = (f, arg) =>
|
|
587
|
+
f(~kind=arg["kind"], ~owner=arg["owner"], ~fieldPath=arg["fieldPath"])
|
|
588
|
+
}
|
|
589
|
+
|
|
547
590
|
module Environment = {
|
|
548
591
|
type t
|
|
549
592
|
|
|
@@ -556,6 +599,8 @@ module Environment = {
|
|
|
556
599
|
@optional
|
|
557
600
|
treatMissingFieldsAsNull: bool,
|
|
558
601
|
missingFieldHandlers: array<MissingFieldHandler.t>,
|
|
602
|
+
@optional
|
|
603
|
+
requiredFieldLogger: RequiredFieldLogger.js,
|
|
559
604
|
}
|
|
560
605
|
|
|
561
606
|
@module("relay-runtime") @new
|
|
@@ -567,6 +612,7 @@ module Environment = {
|
|
|
567
612
|
~getDataID=?,
|
|
568
613
|
~treatMissingFieldsAsNull=?,
|
|
569
614
|
~missingFieldHandlers=?,
|
|
615
|
+
~requiredFieldLogger=?,
|
|
570
616
|
(),
|
|
571
617
|
) =>
|
|
572
618
|
make(
|
|
@@ -579,6 +625,7 @@ module Environment = {
|
|
|
579
625
|
| Some(handlers) => handlers->Belt.Array.concat([nodeInterfaceMissingFieldHandler])
|
|
580
626
|
| None => [nodeInterfaceMissingFieldHandler]
|
|
581
627
|
},
|
|
628
|
+
~requiredFieldLogger=?requiredFieldLogger->Belt.Option.map(RequiredFieldLogger.toJs),
|
|
582
629
|
(),
|
|
583
630
|
),
|
|
584
631
|
)
|
|
@@ -705,18 +752,16 @@ module MakeLoadQuery = (C: MakeLoadQueryConfig) => {
|
|
|
705
752
|
}
|
|
706
753
|
|
|
707
754
|
let queryRefToPromise = token => {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
755
|
+
Js.Promise.make((~resolve, ~reject as _) => {
|
|
756
|
+
switch token->queryRefToObservable {
|
|
757
|
+
| None => resolve(. Error())
|
|
758
|
+
| Some(o) =>
|
|
759
|
+
let _: Observable.subscription = o->{
|
|
760
|
+
open Observable
|
|
761
|
+
subscribe(makeObserver(~complete=() => resolve(. Ok()), ()))
|
|
762
|
+
}
|
|
716
763
|
}
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
promise
|
|
764
|
+
})
|
|
720
765
|
}
|
|
721
766
|
}
|
|
722
767
|
|