rescript-relay 0.0.0-test-rust-compiler-145baf5d → 0.0.0-windows-9ba3fe9e
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 +149 -6
- package/README.md +6 -10
- package/cli/cli.js +29 -35
- package/package.json +20 -11
- package/postinstall.js +21 -7
- package/ppx-linux +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/{ppx-darwin → relay-compiler-win-x64/relay.exe} +0 -0
- package/src/ReactDOMExperimental.bs.js +3 -3
- package/src/ReactDOMExperimental.res +2 -3
- package/src/ReactExperimental.bs.js +14 -1
- package/src/ReactExperimental.res +9 -4
- package/src/ReactExperimental.resi +18 -0
- package/src/RescriptRelay.bs.js +21 -8
- package/src/RescriptRelay.res +70 -15
- package/src/RescriptRelay.resi +57 -13
- package/src/RescriptRelay_Internal.bs.js +42 -13
- package/src/RescriptRelay_Internal.res +22 -18
- package/src/RescriptRelay_Internal.resi +1 -0
- package/src/experimental-router/RescriptRelayRouter.bs.js +2 -1
- package/src/utils.js +184 -163
- package/src/utils.mjs +381 -0
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-windows-9ba3fe9e",
|
|
4
4
|
"main": "src/RescriptRelay.res",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gabriel Nordeborn",
|
|
@@ -19,6 +19,14 @@
|
|
|
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
31
|
"rescript-relay-compiler": "compiler.js",
|
|
24
32
|
"rescript-relay-cli": "cli/cli.js"
|
|
@@ -31,30 +39,31 @@
|
|
|
31
39
|
"test:ci": "jest --ci --runInBand"
|
|
32
40
|
},
|
|
33
41
|
"devDependencies": {
|
|
42
|
+
"rescript": "^9.1.2",
|
|
34
43
|
"@rescript/react": "0.10.3",
|
|
35
|
-
"@testing-library/jest-dom": "^5.16.
|
|
36
|
-
"@testing-library/react": "^13.0.0-alpha.
|
|
44
|
+
"@testing-library/jest-dom": "^5.16.3",
|
|
45
|
+
"@testing-library/react": "^13.0.0-alpha.6",
|
|
37
46
|
"bs-fetch": "^0.5.0",
|
|
38
47
|
"graphql-query-test-mock": "^0.12.1",
|
|
39
48
|
"jest": "^27.2.4",
|
|
40
49
|
"nock": "^11.7.0",
|
|
41
50
|
"node-fetch": "^2.6.0",
|
|
42
|
-
"react": "
|
|
43
|
-
"react-dom": "
|
|
44
|
-
"react-relay": "
|
|
45
|
-
"relay-runtime": "
|
|
51
|
+
"react": "18.0.0",
|
|
52
|
+
"react-dom": "18.0.0",
|
|
53
|
+
"react-relay": "14.1.0",
|
|
54
|
+
"relay-runtime": "14.1.0"
|
|
46
55
|
},
|
|
47
56
|
"peerDependencies": {
|
|
48
57
|
"@rescript/react": "*",
|
|
49
|
-
"react-relay": "
|
|
58
|
+
"react-relay": ">=11.0.0",
|
|
50
59
|
"relay-runtime": "*",
|
|
51
60
|
"rescript": "^9.1.2"
|
|
52
61
|
},
|
|
53
62
|
"dependencies": {
|
|
54
|
-
"
|
|
63
|
+
"detect-libc": "^2.0.1"
|
|
55
64
|
},
|
|
56
65
|
"resolutions": {
|
|
57
|
-
"react": "18.0.0
|
|
58
|
-
"react-dom": "18.0.0
|
|
66
|
+
"react": "18.0.0",
|
|
67
|
+
"react-dom": "18.0.0"
|
|
59
68
|
}
|
|
60
69
|
}
|
package/postinstall.js
CHANGED
|
@@ -10,13 +10,18 @@
|
|
|
10
10
|
var path = require("path");
|
|
11
11
|
var cp = require("child_process");
|
|
12
12
|
var fs = require("fs");
|
|
13
|
+
var { isNonGlibcLinux } = require("detect-libc");
|
|
13
14
|
var platform = process.platform;
|
|
14
15
|
|
|
15
16
|
function getRelayCompilerPlatformSuffix() {
|
|
16
|
-
if (process.platform === "
|
|
17
|
+
if (process.platform === "win32") {
|
|
18
|
+
return "win-x64";
|
|
19
|
+
} else if (process.platform === "darwin" && process.arch === "x64") {
|
|
17
20
|
return "macos-x64";
|
|
18
21
|
} else if (process.platform === "darwin" && process.arch === "arm64") {
|
|
19
22
|
return "macos-arm64";
|
|
23
|
+
} else if (process.platform === "linux" && isNonGlibcLinux) {
|
|
24
|
+
return "linux-musl";
|
|
20
25
|
} else if (process.platform === "linux" && process.arch === "x64") {
|
|
21
26
|
return "linux-x64";
|
|
22
27
|
}
|
|
@@ -104,11 +109,13 @@ function copyPlatformBinaries(platform) {
|
|
|
104
109
|
* Copy the Relay compiler
|
|
105
110
|
*/
|
|
106
111
|
|
|
112
|
+
var platformSuffix = getRelayCompilerPlatformSuffix();
|
|
113
|
+
|
|
107
114
|
fs.copyFileSync(
|
|
108
115
|
path.join(
|
|
109
116
|
__dirname,
|
|
110
|
-
"relay-compiler-" +
|
|
111
|
-
"relay"
|
|
117
|
+
"relay-compiler-" + platformSuffix,
|
|
118
|
+
platformSuffix === "win-x64" ? "relay.exe" : "relay"
|
|
112
119
|
),
|
|
113
120
|
path.join(__dirname, "rescript-relay-compiler.exe")
|
|
114
121
|
);
|
|
@@ -116,7 +123,8 @@ function copyPlatformBinaries(platform) {
|
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
function removeInitialBinaries() {
|
|
119
|
-
fs.unlinkSync(path.join(__dirname, "ppx-
|
|
126
|
+
fs.unlinkSync(path.join(__dirname, "ppx-macos-latest"));
|
|
127
|
+
fs.unlinkSync(path.join(__dirname, "ppx-windows-latest"));
|
|
120
128
|
fs.unlinkSync(path.join(__dirname, "ppx-linux"));
|
|
121
129
|
fs.rmSync(path.join(__dirname, "relay-compiler-linux-x64"), {
|
|
122
130
|
recursive: true,
|
|
@@ -130,6 +138,10 @@ function removeInitialBinaries() {
|
|
|
130
138
|
recursive: true,
|
|
131
139
|
force: true,
|
|
132
140
|
});
|
|
141
|
+
fs.rmSync(path.join(__dirname, "relay-compiler-linux-musl"), {
|
|
142
|
+
recursive: true,
|
|
143
|
+
force: true,
|
|
144
|
+
});
|
|
133
145
|
}
|
|
134
146
|
|
|
135
147
|
switch (platform) {
|
|
@@ -138,13 +150,15 @@ switch (platform) {
|
|
|
138
150
|
console.warn("error: x86 is currently not supported on Windows");
|
|
139
151
|
process.exit(1);
|
|
140
152
|
}
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
copyPlatformBinaries("windows-latest");
|
|
154
|
+
break;
|
|
143
155
|
}
|
|
144
156
|
case "linux":
|
|
145
|
-
case "darwin":
|
|
146
157
|
copyPlatformBinaries(platform);
|
|
147
158
|
break;
|
|
159
|
+
case "darwin":
|
|
160
|
+
copyPlatformBinaries("macos-latest");
|
|
161
|
+
break;
|
|
148
162
|
default:
|
|
149
163
|
console.warn("error: no release built for the " + platform + " platform");
|
|
150
164
|
process.exit(1);
|
package/ppx-linux
CHANGED
|
Binary file
|
package/ppx-macos-latest
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var Client = require("react-dom/client");
|
|
5
5
|
|
|
6
6
|
function renderConcurrentRootAtElementWithId(content, id) {
|
|
7
7
|
var element = document.getElementById(id);
|
|
@@ -12,9 +12,9 @@ function renderConcurrentRootAtElementWithId(content, id) {
|
|
|
12
12
|
Error: new Error()
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
Client.createRoot(element).render(content);
|
|
16
16
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
exports.renderConcurrentRootAtElementWithId = renderConcurrentRootAtElementWithId;
|
|
20
|
-
/* react-dom Not a pure module */
|
|
20
|
+
/* react-dom/client Not a pure module */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
include ReactDOM.Experimental
|
|
2
2
|
|
|
3
|
-
@module("react-dom")
|
|
3
|
+
@module("react-dom/client")
|
|
4
4
|
external createRoot: Dom.element => root = "createRoot"
|
|
5
5
|
|
|
6
6
|
@val @return(nullable)
|
|
@@ -15,6 +15,5 @@ let renderConcurrentRootAtElementWithId: (React.element, string) => unit = (cont
|
|
|
15
15
|
id ++ " found in the HTML.",
|
|
16
16
|
),
|
|
17
17
|
)
|
|
18
|
-
| Some(element) =>
|
|
19
|
-
createRoot(element)->render(content)
|
|
18
|
+
| Some(element) => createRoot(element)->render(content)
|
|
20
19
|
}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var React = require("react");
|
|
5
|
+
|
|
6
|
+
function useTransition(param) {
|
|
7
|
+
var match = React.useTransition();
|
|
8
|
+
var startTransition = match[1];
|
|
9
|
+
return [
|
|
10
|
+
match[0],
|
|
11
|
+
React.useCallback((function (cb) {
|
|
12
|
+
return startTransition(cb, undefined);
|
|
13
|
+
}), [startTransition])
|
|
14
|
+
];
|
|
15
|
+
}
|
|
4
16
|
|
|
5
17
|
var SuspenseList = {};
|
|
6
18
|
|
|
19
|
+
exports.useTransition = useTransition;
|
|
7
20
|
exports.SuspenseList = SuspenseList;
|
|
8
|
-
/*
|
|
21
|
+
/* react Not a pure module */
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
type callback<'input, 'output> = 'input => 'output
|
|
2
|
-
|
|
3
1
|
@module("react")
|
|
4
2
|
external useDeferredValue: 'value => 'value = "useDeferredValue"
|
|
5
3
|
|
|
6
4
|
@module("react")
|
|
7
|
-
external
|
|
8
|
-
|
|
5
|
+
external useTransitionWithOptions: unit => (
|
|
6
|
+
bool,
|
|
7
|
+
(. unit => unit, option<{"name": option<string>}>) => unit,
|
|
8
|
+
) = "useTransition"
|
|
9
|
+
|
|
10
|
+
let useTransition = () => {
|
|
11
|
+
let (isPending, startTransition) = useTransitionWithOptions()
|
|
12
|
+
(isPending, React.useCallback1(cb => startTransition(. cb, None), [startTransition]))
|
|
13
|
+
}
|
|
9
14
|
|
|
10
15
|
module SuspenseList = {
|
|
11
16
|
@module("react") @react.component
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@module("react")
|
|
2
|
+
external useDeferredValue: 'value => 'value = "useDeferredValue"
|
|
3
|
+
|
|
4
|
+
@module("react")
|
|
5
|
+
external useTransitionWithOptions: unit => (
|
|
6
|
+
bool,
|
|
7
|
+
(. unit => unit, option<{"name": option<string>}>) => unit,
|
|
8
|
+
) = "useTransition"
|
|
9
|
+
|
|
10
|
+
let useTransition: unit => (bool, React.callback<unit => unit, unit>)
|
|
11
|
+
|
|
12
|
+
module SuspenseList: {
|
|
13
|
+
@module("react") @react.component
|
|
14
|
+
external make: (
|
|
15
|
+
~children: React.element,
|
|
16
|
+
~revealOrder: [#forwards | #backwards | #together]=?,
|
|
17
|
+
) => React.element = "SuspenseList"
|
|
18
|
+
}
|
package/src/RescriptRelay.bs.js
CHANGED
|
@@ -5,11 +5,11 @@ var Curry = require("rescript/lib/js/curry.js");
|
|
|
5
5
|
var React = require("react");
|
|
6
6
|
var Utils = require("./utils");
|
|
7
7
|
var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
8
|
+
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
8
9
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
9
10
|
var ReactRelay = require("react-relay");
|
|
10
11
|
var RelayRuntime = require("relay-runtime");
|
|
11
12
|
var Caml_exceptions = require("rescript/lib/js/caml_exceptions.js");
|
|
12
|
-
var Hooks = require("react-relay/hooks");
|
|
13
13
|
|
|
14
14
|
function convertObj(prim0, prim1, prim2, prim3) {
|
|
15
15
|
return Utils.traverser(prim0, prim1, prim2, prim3);
|
|
@@ -130,7 +130,11 @@ var Store = {
|
|
|
130
130
|
make: make
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
function
|
|
133
|
+
function toJs(f, arg) {
|
|
134
|
+
return Curry._3(f, arg.kind, arg.owner, arg.fieldPath);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFieldHandlers, requiredFieldLogger, isServer, param) {
|
|
134
138
|
var tmp = {
|
|
135
139
|
network: network,
|
|
136
140
|
store: store,
|
|
@@ -142,6 +146,13 @@ function make$1(network, store, getDataID, treatMissingFieldsAsNull, missingFiel
|
|
|
142
146
|
if (treatMissingFieldsAsNull !== undefined) {
|
|
143
147
|
tmp.treatMissingFieldsAsNull = Caml_option.valFromOption(treatMissingFieldsAsNull);
|
|
144
148
|
}
|
|
149
|
+
var tmp$1 = Belt_Option.map(requiredFieldLogger, toJs);
|
|
150
|
+
if (tmp$1 !== undefined) {
|
|
151
|
+
tmp.requiredFieldLogger = Caml_option.valFromOption(tmp$1);
|
|
152
|
+
}
|
|
153
|
+
if (isServer !== undefined) {
|
|
154
|
+
tmp.isServer = Caml_option.valFromOption(isServer);
|
|
155
|
+
}
|
|
145
156
|
return new RelayRuntime.Environment(tmp);
|
|
146
157
|
}
|
|
147
158
|
|
|
@@ -149,11 +160,10 @@ var Environment = {
|
|
|
149
160
|
make: make$1
|
|
150
161
|
};
|
|
151
162
|
|
|
152
|
-
var provider = ReactRelay.ReactRelayContext.Provider;
|
|
153
|
-
|
|
154
163
|
function RescriptRelay$Context$Provider(Props) {
|
|
155
164
|
var environment = Props.environment;
|
|
156
165
|
var children = Props.children;
|
|
166
|
+
var provider = ReactRelay.ReactRelayContext.Provider;
|
|
157
167
|
return React.createElement(provider, {
|
|
158
168
|
value: {
|
|
159
169
|
environment: environment
|
|
@@ -166,6 +176,10 @@ var Provider = {
|
|
|
166
176
|
make: RescriptRelay$Context$Provider
|
|
167
177
|
};
|
|
168
178
|
|
|
179
|
+
var Context = {
|
|
180
|
+
Provider: Provider
|
|
181
|
+
};
|
|
182
|
+
|
|
169
183
|
var EnvironmentNotFoundInContext = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.EnvironmentNotFoundInContext");
|
|
170
184
|
|
|
171
185
|
function useEnvironmentFromContext(param) {
|
|
@@ -209,7 +223,7 @@ function mapFetchQueryFetchPolicy(x) {
|
|
|
209
223
|
|
|
210
224
|
function MakeLoadQuery(C) {
|
|
211
225
|
var load = function (environment, variables, fetchPolicy, fetchKey, networkCacheConfig, param) {
|
|
212
|
-
return
|
|
226
|
+
return ReactRelay.loadQuery(environment, C.query, Curry._1(C.convertVariables, variables), {
|
|
213
227
|
fetchKey: fetchKey,
|
|
214
228
|
fetchPolicy: mapFetchPolicy(fetchPolicy),
|
|
215
229
|
networkCacheConfig: networkCacheConfig
|
|
@@ -248,9 +262,7 @@ function MakeLoadQuery(C) {
|
|
|
248
262
|
|
|
249
263
|
var Mutation_failed = /* @__PURE__ */Caml_exceptions.create("RescriptRelay.Mutation_failed");
|
|
250
264
|
|
|
251
|
-
var
|
|
252
|
-
Provider: Provider
|
|
253
|
-
};
|
|
265
|
+
var RequiredFieldLogger = {};
|
|
254
266
|
|
|
255
267
|
exports.convertObj = convertObj;
|
|
256
268
|
exports.RecordProxy = RecordProxy;
|
|
@@ -263,6 +275,7 @@ exports.Network = Network;
|
|
|
263
275
|
exports.RecordSource = RecordSource;
|
|
264
276
|
exports.Store = Store;
|
|
265
277
|
exports.Disposable = Disposable;
|
|
278
|
+
exports.RequiredFieldLogger = RequiredFieldLogger;
|
|
266
279
|
exports.Environment = Environment;
|
|
267
280
|
exports.mapFetchPolicy = mapFetchPolicy;
|
|
268
281
|
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,16 +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("
|
|
43
|
-
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,
|
|
44
68
|
}
|
|
45
69
|
|
|
46
70
|
@module("relay-runtime")
|
|
@@ -142,6 +166,10 @@ module RecordProxy = {
|
|
|
142
166
|
external setLinkedRecord: (t, ~record: t, ~name: string, ~arguments: arguments=?, unit) => t =
|
|
143
167
|
"setLinkedRecord"
|
|
144
168
|
|
|
169
|
+
// `setLinkedRecord` can't be used for "deleting" linked record fields.
|
|
170
|
+
// It throws an error if anything besides `record` is received:
|
|
171
|
+
// https://github.com/facebook/relay/blob/bd2e4173ef726804b2ed4e76d88a7bcc1753c496/packages/relay-runtime/mutations/RelayRecordProxy.js#L92
|
|
172
|
+
// However, `setValue` can be used for this purpose instead.
|
|
145
173
|
@send
|
|
146
174
|
external setLinkedRecordToUndefined: (
|
|
147
175
|
t,
|
|
@@ -149,7 +177,7 @@ module RecordProxy = {
|
|
|
149
177
|
~name: string,
|
|
150
178
|
~arguments: arguments=?,
|
|
151
179
|
unit,
|
|
152
|
-
) => t = "
|
|
180
|
+
) => t = "setValue"
|
|
153
181
|
|
|
154
182
|
@send
|
|
155
183
|
external setLinkedRecordToNull: (
|
|
@@ -158,7 +186,7 @@ module RecordProxy = {
|
|
|
158
186
|
~name: string,
|
|
159
187
|
~arguments: arguments=?,
|
|
160
188
|
unit,
|
|
161
|
-
) => t = "
|
|
189
|
+
) => t = "setValue"
|
|
162
190
|
|
|
163
191
|
@send
|
|
164
192
|
external setLinkedRecords: (
|
|
@@ -169,6 +197,10 @@ module RecordProxy = {
|
|
|
169
197
|
unit,
|
|
170
198
|
) => t = "setLinkedRecords"
|
|
171
199
|
|
|
200
|
+
// `setLinkedRecords` can't be used for "deleting" linked records.
|
|
201
|
+
// It throws an error if anything besides an array of `records` is received:
|
|
202
|
+
// https://github.com/facebook/relay/blob/bd2e4173ef726804b2ed4e76d88a7bcc1753c496/packages/relay-runtime/mutations/RelayRecordProxy.js#L140
|
|
203
|
+
// However, `setValue` can be used for this purpose instead.
|
|
172
204
|
@send
|
|
173
205
|
external setLinkedRecordsToUndefined: (
|
|
174
206
|
t,
|
|
@@ -176,7 +208,7 @@ module RecordProxy = {
|
|
|
176
208
|
~name: string,
|
|
177
209
|
~arguments: arguments=?,
|
|
178
210
|
unit,
|
|
179
|
-
) => t = "
|
|
211
|
+
) => t = "setValue"
|
|
180
212
|
|
|
181
213
|
@send
|
|
182
214
|
external setLinkedRecordsToNull: (
|
|
@@ -185,7 +217,7 @@ module RecordProxy = {
|
|
|
185
217
|
~name: string,
|
|
186
218
|
~arguments: arguments=?,
|
|
187
219
|
unit,
|
|
188
|
-
) => t = "
|
|
220
|
+
) => t = "setValue"
|
|
189
221
|
|
|
190
222
|
@send
|
|
191
223
|
external setValueToUndefined: (
|
|
@@ -548,6 +580,20 @@ module Store = {
|
|
|
548
580
|
|
|
549
581
|
@send external getSource: t => RecordSource.t = "getSource"
|
|
550
582
|
@send external publish: (t, RecordSource.t) => unit = "publish"
|
|
583
|
+
@send external holdGC: t => unit = "holdGC"
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
module RequiredFieldLogger = {
|
|
587
|
+
type kind = [#"missing_field.log" | #"missing_field.throw"]
|
|
588
|
+
|
|
589
|
+
type arg = {"kind": kind, "owner": string, "fieldPath": string}
|
|
590
|
+
|
|
591
|
+
type js = arg => unit
|
|
592
|
+
|
|
593
|
+
type t = (~kind: kind, ~owner: string, ~fieldPath: string) => unit
|
|
594
|
+
|
|
595
|
+
let toJs: t => js = (f, arg) =>
|
|
596
|
+
f(~kind=arg["kind"], ~owner=arg["owner"], ~fieldPath=arg["fieldPath"])
|
|
551
597
|
}
|
|
552
598
|
|
|
553
599
|
module Environment = {
|
|
@@ -562,6 +608,10 @@ module Environment = {
|
|
|
562
608
|
@optional
|
|
563
609
|
treatMissingFieldsAsNull: bool,
|
|
564
610
|
missingFieldHandlers: array<MissingFieldHandler.t>,
|
|
611
|
+
@optional
|
|
612
|
+
requiredFieldLogger: RequiredFieldLogger.js,
|
|
613
|
+
@optional
|
|
614
|
+
isServer: bool,
|
|
565
615
|
}
|
|
566
616
|
|
|
567
617
|
@module("relay-runtime") @new
|
|
@@ -573,6 +623,8 @@ module Environment = {
|
|
|
573
623
|
~getDataID=?,
|
|
574
624
|
~treatMissingFieldsAsNull=?,
|
|
575
625
|
~missingFieldHandlers=?,
|
|
626
|
+
~requiredFieldLogger=?,
|
|
627
|
+
~isServer=?,
|
|
576
628
|
(),
|
|
577
629
|
) =>
|
|
578
630
|
make(
|
|
@@ -585,6 +637,8 @@ module Environment = {
|
|
|
585
637
|
| Some(handlers) => handlers->Belt.Array.concat([nodeInterfaceMissingFieldHandler])
|
|
586
638
|
| None => [nodeInterfaceMissingFieldHandler]
|
|
587
639
|
},
|
|
640
|
+
~requiredFieldLogger=?requiredFieldLogger->Belt.Option.map(RequiredFieldLogger.toJs),
|
|
641
|
+
~isServer?,
|
|
588
642
|
(),
|
|
589
643
|
),
|
|
590
644
|
)
|
|
@@ -602,15 +656,16 @@ module Context = {
|
|
|
602
656
|
|
|
603
657
|
@module("react-relay")
|
|
604
658
|
external context: React.Context.t<option<contextShape>> = "ReactRelayContext"
|
|
605
|
-
let provider = React.Context.provider(context)
|
|
606
659
|
|
|
607
660
|
module Provider = {
|
|
608
661
|
@react.component
|
|
609
|
-
let make = (~environment: Environment.t, ~children) =>
|
|
662
|
+
let make = (~environment: Environment.t, ~children) => {
|
|
663
|
+
let provider = React.Context.provider(context)
|
|
610
664
|
React.createElement(
|
|
611
665
|
provider,
|
|
612
666
|
{"value": Some({"environment": environment}), "children": children},
|
|
613
667
|
)
|
|
668
|
+
}
|
|
614
669
|
}
|
|
615
670
|
}
|
|
616
671
|
|
|
@@ -662,7 +717,7 @@ type loadQueryConfig = {
|
|
|
662
717
|
networkCacheConfig: option<cacheConfig>,
|
|
663
718
|
}
|
|
664
719
|
|
|
665
|
-
@module("react-relay
|
|
720
|
+
@module("react-relay")
|
|
666
721
|
external loadQuery: (Environment.t, queryNode<'a>, 'variables, loadQueryConfig) => 'queryResponse =
|
|
667
722
|
"loadQuery"
|
|
668
723
|
|
|
@@ -734,6 +789,6 @@ external commitLocalUpdate: (
|
|
|
734
789
|
~updater: RecordSourceSelectorProxy.t => unit,
|
|
735
790
|
) => unit = "commitLocalUpdate"
|
|
736
791
|
|
|
737
|
-
@module("react-relay
|
|
792
|
+
@module("react-relay")
|
|
738
793
|
external useSubscribeToInvalidationState: (array<dataId>, unit => unit) => Disposable.t =
|
|
739
794
|
"useSubscribeToInvalidationState"
|