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/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(
|
|
@@ -94,14 +90,40 @@ external isClientID: dataId => bool = "isClientID"
|
|
|
94
90
|
"Relay feature flags. Mutate this record as soon as your application boots to enable/disable features."
|
|
95
91
|
)
|
|
96
92
|
type featureFlags = {
|
|
93
|
+
@as("DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES")
|
|
94
|
+
mutable delayCleanupOfPendingPreloadQueries: bool,
|
|
95
|
+
@as("ENABLE_CLIENT_EDGES")
|
|
96
|
+
mutable enableClientEdges: bool,
|
|
97
97
|
@as("ENABLE_VARIABLE_CONNECTION_KEY")
|
|
98
98
|
mutable enableVariableConnectionKey: bool,
|
|
99
99
|
@as("ENABLE_PARTIAL_RENDERING_DEFAULT")
|
|
100
100
|
mutable enablePartialRenderingDefault: bool,
|
|
101
|
-
@as("
|
|
102
|
-
mutable
|
|
103
|
-
@as("
|
|
104
|
-
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,
|
|
105
127
|
}
|
|
106
128
|
|
|
107
129
|
@ocaml.doc(
|
|
@@ -110,12 +132,10 @@ type featureFlags = {
|
|
|
110
132
|
@module("relay-runtime")
|
|
111
133
|
external relayFeatureFlags: featureFlags = "RelayFeatureFlags"
|
|
112
134
|
|
|
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.
|
|
135
|
+
@ocaml.doc("Representing all records in the store serialized to JSON in a way that you can use to re-hydrate the store.
|
|
115
136
|
|
|
116
|
-
See `RecordSource.toJSON` for how to produce it."
|
|
117
|
-
|
|
118
|
-
type recordSourceRecords
|
|
137
|
+
See `RecordSource.toJSON` for how to produce it.")
|
|
138
|
+
type recordSourceRecords = Js.Json.t
|
|
119
139
|
|
|
120
140
|
@ocaml.doc(
|
|
121
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."
|
|
@@ -357,13 +377,11 @@ module RecordProxy: {
|
|
|
357
377
|
unit,
|
|
358
378
|
) => t = "setLinkedRecords"
|
|
359
379
|
|
|
360
|
-
@ocaml.doc(
|
|
361
|
-
"Invalidates this record.
|
|
380
|
+
@ocaml.doc("Invalidates this record.
|
|
362
381
|
|
|
363
382
|
Invalidating a record means that the _next_ time Relay evaluates this record, it'll be treated as missing.
|
|
364
383
|
|
|
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
|
-
)
|
|
384
|
+
_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
385
|
@send
|
|
368
386
|
external invalidateRecord: t => unit = "invalidateRecord"
|
|
369
387
|
}
|
|
@@ -426,11 +444,9 @@ module ReadOnlyRecordSourceProxy: {
|
|
|
426
444
|
external getRoot: t => RecordProxy.t = "getRoot"
|
|
427
445
|
}
|
|
428
446
|
|
|
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/).
|
|
447
|
+
@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
448
|
|
|
432
|
-
Feed a list of missing field handlers into `Environment.make` if you want to use them."
|
|
433
|
-
)
|
|
449
|
+
Feed a list of missing field handlers into `Environment.make` if you want to use them.")
|
|
434
450
|
module MissingFieldHandler: {
|
|
435
451
|
@@ocaml.warning("-30")
|
|
436
452
|
|
|
@@ -607,9 +623,9 @@ module Observable: {
|
|
|
607
623
|
|
|
608
624
|
@ocaml.doc("This sink can be used to give the observable new data.")
|
|
609
625
|
type sink<'response> = {
|
|
610
|
-
next: 'response => unit,
|
|
611
|
-
error: Js.Exn.t => unit,
|
|
612
|
-
complete: unit => unit,
|
|
626
|
+
next: (. 'response) => unit,
|
|
627
|
+
error: (. Js.Exn.t) => unit,
|
|
628
|
+
complete: (. unit) => unit,
|
|
613
629
|
closed: bool,
|
|
614
630
|
}
|
|
615
631
|
|
|
@@ -624,10 +640,10 @@ module Observable: {
|
|
|
624
640
|
|
|
625
641
|
@ocaml.doc("Create an observer.") @obj
|
|
626
642
|
external makeObserver: (
|
|
627
|
-
~start: subscription => unit=?,
|
|
628
|
-
~next: 'response => unit=?,
|
|
629
|
-
~error: Js.Exn.t => unit=?,
|
|
630
|
-
~complete: unit => unit=?,
|
|
643
|
+
~start: @uncurry subscription => unit=?,
|
|
644
|
+
~next: @uncurry 'response => unit=?,
|
|
645
|
+
~error: @uncurry Js.Exn.t => unit=?,
|
|
646
|
+
~complete: @uncurry unit => unit=?,
|
|
631
647
|
~unsubscribe: subscription => unit=?,
|
|
632
648
|
unit,
|
|
633
649
|
) => observer<'response> = ""
|
|
@@ -646,7 +662,7 @@ module Observable: {
|
|
|
646
662
|
"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
663
|
)
|
|
648
664
|
@send
|
|
649
|
-
external toPromise: t<'t> => Promise.t<'t> = "toPromise"
|
|
665
|
+
external toPromise: t<'t> => Js.Promise.t<'t> = "toPromise"
|
|
650
666
|
}
|
|
651
667
|
|
|
652
668
|
@ocaml.doc("Represents the network layer.")
|
|
@@ -737,7 +753,7 @@ module Store: {
|
|
|
737
753
|
~source: RecordSource.t,
|
|
738
754
|
~gcReleaseBufferSize: /* `gcReleaseBufferSize` controls how many queries are allowed to be cached by default. Increase this to increase the size of the cache. */
|
|
739
755
|
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.
|
|
756
|
+
~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
757
|
unit,
|
|
742
758
|
) => t
|
|
743
759
|
|
|
@@ -764,6 +780,18 @@ module Disposable: {
|
|
|
764
780
|
@ocaml.doc("Dispose the `Disposable`.") @send external dispose: t => unit = "dispose"
|
|
765
781
|
}
|
|
766
782
|
|
|
783
|
+
@ocaml.doc(
|
|
784
|
+
"A required field logger, which gets called when a field annotated with the @required directive was missing from the response"
|
|
785
|
+
)
|
|
786
|
+
module RequiredFieldLogger: {
|
|
787
|
+
type kind = [#"missing_field.log" | #"missing_field.throw"]
|
|
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
|
+
type t = (~kind: kind, ~owner: string, ~fieldPath: string) => unit
|
|
793
|
+
}
|
|
794
|
+
|
|
767
795
|
@ocaml.doc(
|
|
768
796
|
"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."
|
|
769
797
|
)
|
|
@@ -781,6 +809,7 @@ module Environment: {
|
|
|
781
809
|
) => string=?,
|
|
782
810
|
~treatMissingFieldsAsNull: bool=?,
|
|
783
811
|
~missingFieldHandlers: array<MissingFieldHandler.t>=?,
|
|
812
|
+
~requiredFieldLogger: RequiredFieldLogger.t=?,
|
|
784
813
|
unit,
|
|
785
814
|
) => t
|
|
786
815
|
|
|
@@ -790,10 +819,8 @@ module Environment: {
|
|
|
790
819
|
@ocaml.doc("Given an `operationDescriptor`, commits the corresponding payload.") @send
|
|
791
820
|
external commitPayload: (t, operationDescriptor, 'payload) => unit = "commitPayload"
|
|
792
821
|
|
|
793
|
-
@ocaml.doc(
|
|
794
|
-
|
|
795
|
-
You should use the generated `Query.retain` function on your queries instead of using this directly."
|
|
796
|
-
)
|
|
822
|
+
@ocaml.doc("Given an `operationDescriptor`, retains the corresponding operation so any data referenced by it isn't garbage collected.
|
|
823
|
+
You should use the generated `Query.retain` function on your queries instead of using this directly.")
|
|
797
824
|
@send
|
|
798
825
|
external retain: (t, operationDescriptor) => Disposable.t = "retain"
|
|
799
826
|
}
|
|
@@ -897,5 +924,5 @@ module MakeLoadQuery: (C: MakeLoadQueryConfig) =>
|
|
|
897
924
|
) => C.loadedQueryRef
|
|
898
925
|
|
|
899
926
|
let queryRefToObservable: C.loadedQueryRef => option<Observable.t<C.response>>
|
|
900
|
-
let queryRefToPromise: C.loadedQueryRef => Promise.t<Belt.Result.t<unit, unit>>
|
|
927
|
+
let queryRefToPromise: C.loadedQueryRef => Js.Promise.t<Belt.Result.t<unit, unit>>
|
|
901
928
|
}
|
|
@@ -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
|
}
|
|
@@ -233,7 +233,7 @@ module RouteRenderer = {
|
|
|
233
233
|
let (initialized, setInitialized) = React.useState(() => false)
|
|
234
234
|
let router = use()
|
|
235
235
|
|
|
236
|
-
let (
|
|
236
|
+
let (isPending, startTransition) = ReactExperimental.useTransition()
|
|
237
237
|
|
|
238
238
|
let (routeEntry, setRouteEntry) = React.useState(() => router.get())
|
|
239
239
|
|
|
@@ -306,10 +306,12 @@ module Link = {
|
|
|
306
306
|
~className=?,
|
|
307
307
|
~classNameDynamic=?,
|
|
308
308
|
~target as browserTarget=?,
|
|
309
|
+
~tabIndex=?,
|
|
309
310
|
~mode=?,
|
|
310
311
|
~render=?,
|
|
311
312
|
~preloadOnHover=?,
|
|
312
313
|
~children,
|
|
314
|
+
~onClick=?,
|
|
313
315
|
(),
|
|
314
316
|
) => {
|
|
315
317
|
let router = use()
|
|
@@ -350,12 +352,19 @@ module Link = {
|
|
|
350
352
|
}}
|
|
351
353
|
?title
|
|
352
354
|
?id
|
|
355
|
+
?tabIndex
|
|
353
356
|
className={className->Belt.Option.getWithDefault("") ++
|
|
354
357
|
switch classNameDynamic {
|
|
355
358
|
| Some(f) => " " ++ f(url, to_->Url.make)
|
|
356
359
|
| None => ""
|
|
357
360
|
}}
|
|
358
|
-
onClick=
|
|
361
|
+
onClick={e => {
|
|
362
|
+
changeRoute(e)
|
|
363
|
+
switch onClick {
|
|
364
|
+
| None => ()
|
|
365
|
+
| Some(onClick) => onClick()
|
|
366
|
+
}
|
|
367
|
+
}}
|
|
359
368
|
onMouseDown={_ => preload()}
|
|
360
369
|
onTouchStart={_ => preload()}
|
|
361
370
|
onMouseEnter={_ =>
|
|
@@ -56,6 +56,7 @@ module Link: {
|
|
|
56
56
|
~className: string=?,
|
|
57
57
|
~classNameDynamic: (RescriptReactRouter.url, RescriptReactRouter.url) => string=?,
|
|
58
58
|
~target: [#self | #blank]=?,
|
|
59
|
+
~tabIndex: int=?,
|
|
59
60
|
~mode: [#push | #replace]=?,
|
|
60
61
|
~render: (
|
|
61
62
|
~preload: unit => unit,
|
|
@@ -65,6 +66,7 @@ module Link: {
|
|
|
65
66
|
) => React.element=?,
|
|
66
67
|
~preloadOnHover: bool=?,
|
|
67
68
|
~children: React.element,
|
|
69
|
+
~onClick: unit => unit=?,
|
|
68
70
|
unit,
|
|
69
71
|
) => React.element
|
|
70
72
|
}
|