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/src/RescriptRelay.resi
CHANGED
|
@@ -90,16 +90,40 @@ external isClientID: dataId => bool = "isClientID"
|
|
|
90
90
|
"Relay feature flags. Mutate this record as soon as your application boots to enable/disable features."
|
|
91
91
|
)
|
|
92
92
|
type featureFlags = {
|
|
93
|
+
@as("DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES")
|
|
94
|
+
mutable delayCleanupOfPendingPreloadQueries: bool,
|
|
95
|
+
@as("ENABLE_CLIENT_EDGES")
|
|
96
|
+
mutable enableClientEdges: bool,
|
|
93
97
|
@as("ENABLE_VARIABLE_CONNECTION_KEY")
|
|
94
98
|
mutable enableVariableConnectionKey: bool,
|
|
95
99
|
@as("ENABLE_PARTIAL_RENDERING_DEFAULT")
|
|
96
100
|
mutable enablePartialRenderingDefault: bool,
|
|
97
|
-
@as("
|
|
98
|
-
mutable
|
|
99
|
-
@as("
|
|
100
|
-
mutable
|
|
101
|
-
@as("
|
|
102
|
-
mutable
|
|
101
|
+
@as("ENABLE_REACT_FLIGHT_COMPONENT_FIELD")
|
|
102
|
+
mutable enableReactFlightComponentField: bool,
|
|
103
|
+
@as("ENABLE_RELAY_RESOLVERS")
|
|
104
|
+
mutable enableRelayResolvers: bool,
|
|
105
|
+
@as("ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION")
|
|
106
|
+
mutable enableGetFragmentIdentifierOptimization: bool,
|
|
107
|
+
@as("ENABLE_FRIENDLY_QUERY_NAME_GQL_URL")
|
|
108
|
+
mutable enableFriendlyQueryNameGqlUrl: bool,
|
|
109
|
+
@as("ENABLE_LOAD_QUERY_REQUEST_DEDUPING")
|
|
110
|
+
mutable enableLoadQueryRequestDeduping: bool,
|
|
111
|
+
@as("ENABLE_DO_NOT_WRAP_LIVE_QUERY")
|
|
112
|
+
mutable enableDoNotWrapLiveQuery: bool,
|
|
113
|
+
@as("ENABLE_NOTIFY_SUBSCRIPTION")
|
|
114
|
+
mutable enableNotifySubscription: bool,
|
|
115
|
+
@as("ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT")
|
|
116
|
+
mutable enableContainersSubscribeOnCommit: bool,
|
|
117
|
+
@as("ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT")
|
|
118
|
+
mutable enableQueryRendererOffscreenSupport: bool,
|
|
119
|
+
@as("MAX_DATA_ID_LENGTH")
|
|
120
|
+
mutable maxDataIdLength: option<int>,
|
|
121
|
+
@as("REFACTOR_SUSPENSE_RESOURCE")
|
|
122
|
+
mutable refactorSuspenseResource: bool,
|
|
123
|
+
@as("STRING_INTERN_LEVEL")
|
|
124
|
+
mutable stringInternLevel: int,
|
|
125
|
+
@as("USE_REACT_CACHE")
|
|
126
|
+
mutable useReactCache: bool,
|
|
103
127
|
}
|
|
104
128
|
|
|
105
129
|
@ocaml.doc(
|
|
@@ -108,10 +132,10 @@ type featureFlags = {
|
|
|
108
132
|
@module("relay-runtime")
|
|
109
133
|
external relayFeatureFlags: featureFlags = "RelayFeatureFlags"
|
|
110
134
|
|
|
111
|
-
@ocaml.doc("
|
|
135
|
+
@ocaml.doc("Representing all records in the store serialized to JSON in a way that you can use to re-hydrate the store.
|
|
112
136
|
|
|
113
137
|
See `RecordSource.toJSON` for how to produce it.")
|
|
114
|
-
type recordSourceRecords
|
|
138
|
+
type recordSourceRecords = Js.Json.t
|
|
115
139
|
|
|
116
140
|
@ocaml.doc(
|
|
117
141
|
"The `dataId` for the Relay store's root. Useful when for example referencing the `parentID` of a connection that's on the store root."
|
|
@@ -321,7 +345,7 @@ module RecordProxy: {
|
|
|
321
345
|
~name: string,
|
|
322
346
|
~arguments: arguments=?,
|
|
323
347
|
unit,
|
|
324
|
-
) => t = "
|
|
348
|
+
) => t = "setValue"
|
|
325
349
|
|
|
326
350
|
@ocaml.doc("Sets this linked record to `null`.") @send
|
|
327
351
|
external setLinkedRecordToNull: (
|
|
@@ -330,7 +354,7 @@ module RecordProxy: {
|
|
|
330
354
|
~name: string,
|
|
331
355
|
~arguments: arguments=?,
|
|
332
356
|
unit,
|
|
333
|
-
) => t = "
|
|
357
|
+
) => t = "setValue"
|
|
334
358
|
|
|
335
359
|
@ocaml.doc(
|
|
336
360
|
"Sets the field holding these linked records to `undefined` (meaning Relay will treat it as missing data)."
|
|
@@ -342,7 +366,7 @@ module RecordProxy: {
|
|
|
342
366
|
~name: string,
|
|
343
367
|
~arguments: arguments=?,
|
|
344
368
|
unit,
|
|
345
|
-
) => t = "
|
|
369
|
+
) => t = "setValue"
|
|
346
370
|
|
|
347
371
|
@ocaml.doc("Sets the field holding these linked records to `null`.") @send
|
|
348
372
|
external setLinkedRecordsToNull: (
|
|
@@ -351,7 +375,7 @@ module RecordProxy: {
|
|
|
351
375
|
~name: string,
|
|
352
376
|
~arguments: arguments=?,
|
|
353
377
|
unit,
|
|
354
|
-
) => t = "
|
|
378
|
+
) => t = "setValue"
|
|
355
379
|
|
|
356
380
|
@ocaml.doc("Invalidates this record.
|
|
357
381
|
|
|
@@ -741,6 +765,12 @@ module Store: {
|
|
|
741
765
|
)
|
|
742
766
|
@send
|
|
743
767
|
external publish: (t, RecordSource.t) => unit = "publish"
|
|
768
|
+
|
|
769
|
+
@ocaml.doc(
|
|
770
|
+
"Informes the store to stop its normal garbage collection processes. This prevents data being lost between calling relay's `fetchQuery` any serialization process (eg: toJSON)"
|
|
771
|
+
)
|
|
772
|
+
@send
|
|
773
|
+
external holdGC: t => unit = "holdGC"
|
|
744
774
|
}
|
|
745
775
|
|
|
746
776
|
@ocaml.doc("Internal, do not use.")
|
|
@@ -756,6 +786,18 @@ module Disposable: {
|
|
|
756
786
|
@ocaml.doc("Dispose the `Disposable`.") @send external dispose: t => unit = "dispose"
|
|
757
787
|
}
|
|
758
788
|
|
|
789
|
+
@ocaml.doc(
|
|
790
|
+
"A required field logger, which gets called when a field annotated with the @required directive was missing from the response"
|
|
791
|
+
)
|
|
792
|
+
module RequiredFieldLogger: {
|
|
793
|
+
type kind = [#"missing_field.log" | #"missing_field.throw"]
|
|
794
|
+
|
|
795
|
+
@ocaml.doc(
|
|
796
|
+
"A required field logger, which gets called when a field annotated with the @required directive was missing from the response"
|
|
797
|
+
)
|
|
798
|
+
type t = (~kind: kind, ~owner: string, ~fieldPath: string) => unit
|
|
799
|
+
}
|
|
800
|
+
|
|
759
801
|
@ocaml.doc(
|
|
760
802
|
"Module representing the environment, which you'll need to use and pass to various functions. Takes a few configuration options like store and network layer."
|
|
761
803
|
)
|
|
@@ -773,6 +815,8 @@ module Environment: {
|
|
|
773
815
|
) => string=?,
|
|
774
816
|
~treatMissingFieldsAsNull: bool=?,
|
|
775
817
|
~missingFieldHandlers: array<MissingFieldHandler.t>=?,
|
|
818
|
+
~requiredFieldLogger: RequiredFieldLogger.t=?,
|
|
819
|
+
~isServer: bool=?,
|
|
776
820
|
unit,
|
|
777
821
|
) => t
|
|
778
822
|
|
|
@@ -854,7 +898,7 @@ external commitLocalUpdate: (
|
|
|
854
898
|
@ocaml.doc(
|
|
855
899
|
"Allows you to subscribe to when a record, connection, or even the store itself is invalidated, and then react to that."
|
|
856
900
|
)
|
|
857
|
-
@module("react-relay
|
|
901
|
+
@module("react-relay")
|
|
858
902
|
external useSubscribeToInvalidationState: (array<dataId>, unit => unit) => Disposable.t =
|
|
859
903
|
"useSubscribeToInvalidationState"
|
|
860
904
|
|
|
@@ -3,23 +3,51 @@
|
|
|
3
3
|
|
|
4
4
|
var Curry = require("rescript/lib/js/curry.js");
|
|
5
5
|
var React = require("react");
|
|
6
|
+
var Js_dict = require("rescript/lib/js/js_dict.js");
|
|
7
|
+
var Caml_obj = require("rescript/lib/js/caml_obj.js");
|
|
8
|
+
var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
9
|
+
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
6
10
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var newObj = {};
|
|
12
|
+
function internal_keepMapFieldsRaw(record, f) {
|
|
13
|
+
return Belt_Option.map(record, (function (obj) {
|
|
14
|
+
return Js_dict.fromArray(Belt_Array.keepMap(Js_dict.entries(obj), f));
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
function internal_cleanObjectFromUndefinedRaw(record) {
|
|
19
|
+
return internal_keepMapFieldsRaw(record, (function (param) {
|
|
20
|
+
var value = param[1];
|
|
21
|
+
if (value !== undefined) {
|
|
22
|
+
return [
|
|
23
|
+
param[0],
|
|
24
|
+
Caml_option.valFromOption(value)
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
function internal_removeUndefinedAndConvertNullsRaw(record) {
|
|
32
|
+
return internal_keepMapFieldsRaw(record, (function (param) {
|
|
33
|
+
var value = param[1];
|
|
34
|
+
var key = param[0];
|
|
35
|
+
var match = Caml_obj.caml_equal(value, Caml_option.some(undefined));
|
|
36
|
+
if (value !== undefined) {
|
|
37
|
+
return [
|
|
38
|
+
key,
|
|
39
|
+
Caml_option.valFromOption(value)
|
|
40
|
+
];
|
|
41
|
+
} else if (match) {
|
|
42
|
+
return [
|
|
43
|
+
key,
|
|
44
|
+
null
|
|
45
|
+
];
|
|
46
|
+
} else {
|
|
47
|
+
return ;
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
23
51
|
|
|
24
52
|
function internal_useConvertedValue(convert, v) {
|
|
25
53
|
return React.useMemo((function () {
|
|
@@ -38,5 +66,6 @@ function internal_nullableToOptionalExnHandler(x) {
|
|
|
38
66
|
|
|
39
67
|
exports.internal_useConvertedValue = internal_useConvertedValue;
|
|
40
68
|
exports.internal_cleanObjectFromUndefinedRaw = internal_cleanObjectFromUndefinedRaw;
|
|
69
|
+
exports.internal_removeUndefinedAndConvertNullsRaw = internal_removeUndefinedAndConvertNullsRaw;
|
|
41
70
|
exports.internal_nullableToOptionalExnHandler = internal_nullableToOptionalExnHandler;
|
|
42
71
|
/* react Not a pure module */
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return obj;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
var newObj = {};
|
|
1
|
+
let internal_keepMapFieldsRaw = (record, f) =>
|
|
2
|
+
record
|
|
3
|
+
->Obj.magic
|
|
4
|
+
->Belt.Option.map(obj => obj->Js.Dict.entries->Belt.Array.keepMap(f)->Js.Dict.fromArray)
|
|
5
|
+
->Obj.magic
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
// we need to do this until we can use @obj on record types
|
|
8
|
+
// see https://github.com/rescript-lang/rescript-compiler/pull/5253
|
|
9
|
+
let internal_cleanObjectFromUndefinedRaw = record =>
|
|
10
|
+
internal_keepMapFieldsRaw(record, ((key, value)) => {
|
|
11
|
+
switch value {
|
|
12
|
+
| Some(value) => Some((key, value))
|
|
13
|
+
| None => None
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
17
|
+
let internal_removeUndefinedAndConvertNullsRaw = record =>
|
|
18
|
+
internal_keepMapFieldsRaw(record, ((key, value)) => {
|
|
19
|
+
switch (value, value == Some(None)) {
|
|
20
|
+
| (Some(value), _) => Some((key, Js.Nullable.return(value)))
|
|
21
|
+
| (_, true) => Some((key, Js.Nullable.null))
|
|
22
|
+
| (None, _) => None
|
|
23
|
+
}
|
|
24
|
+
})
|
|
21
25
|
|
|
22
26
|
let internal_useConvertedValue = (convert, v) => React.useMemo1(() => convert(v), [v])
|
|
23
27
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let internal_useConvertedValue: ('a => 'a, 'a) => 'a
|
|
2
2
|
let internal_cleanObjectFromUndefinedRaw: 't => 't
|
|
3
|
+
let internal_removeUndefinedAndConvertNullsRaw: 't => 't
|
|
3
4
|
let internal_nullableToOptionalExnHandler: option<option<'b> => 'a> => option<
|
|
4
5
|
Js.Nullable.t<'b> => 'a,
|
|
5
6
|
>
|
|
@@ -9,6 +9,7 @@ var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
|
9
9
|
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
10
10
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
11
11
|
var Caml_exceptions = require("rescript/lib/js/caml_exceptions.js");
|
|
12
|
+
var ReactExperimental = require("../ReactExperimental.bs.js");
|
|
12
13
|
var RescriptReactRouter = require("@rescript/react/src/RescriptReactRouter.bs.js");
|
|
13
14
|
|
|
14
15
|
function matchesUrl(t, url) {
|
|
@@ -242,7 +243,7 @@ function RescriptRelayRouter$RouteRenderer(Props) {
|
|
|
242
243
|
});
|
|
243
244
|
var initialized = match[0];
|
|
244
245
|
var router = React.useContext(context);
|
|
245
|
-
var match$1 =
|
|
246
|
+
var match$1 = ReactExperimental.useTransition(undefined);
|
|
246
247
|
var startTransition = match$1[1];
|
|
247
248
|
var match$2 = React.useState(function () {
|
|
248
249
|
return Curry._1(router.get, undefined);
|