rescript-relay 3.5.0 → 4.0.0
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 +10 -0
- package/README.md +14 -4
- package/package.json +12 -7
- package/ppx-linux +0 -0
- package/ppx-macos-arm64 +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/relay-compiler-win-x64/relay.exe +0 -0
- package/src/RescriptRelay.bs.js +151 -167
- package/src/RescriptRelay.res +61 -63
- package/src/RescriptRelay.resi +84 -110
- package/src/RescriptRelayUtils.bs.js +44 -47
- package/src/RescriptRelayUtils.res +3 -3
- package/src/RescriptRelay_Fragment.bs.js +56 -81
- package/src/RescriptRelay_Fragment.res +60 -52
- package/src/RescriptRelay_Fragment.resi +5 -5
- package/src/RescriptRelay_Internal.bs.js +38 -47
- package/src/RescriptRelay_Internal.res +5 -5
- package/src/RescriptRelay_Internal.resi +2 -4
- package/src/RescriptRelay_Mutation.bs.js +28 -42
- package/src/RescriptRelay_Mutation.res +4 -4
- package/src/RescriptRelay_Query.bs.js +43 -64
- package/src/RescriptRelay_Query.res +16 -13
- package/src/RescriptRelay_Query.resi +1 -1
- package/src/RescriptRelay_RelayResolvers.bs.js +2 -4
- package/src/RescriptRelay_Subscriptions.bs.js +9 -15
- package/src/RescriptRelay_Subscriptions.res +1 -1
- package/src/RescriptRelay_Subscriptions.resi +1 -1
- package/src/ReactDOMExperimental.bs.js +0 -23
- package/src/ReactDOMExperimental.res +0 -16
package/src/RescriptRelay.resi
CHANGED
|
@@ -44,7 +44,7 @@ type dataIdObject = {id: dataId}
|
|
|
44
44
|
/** A module for results originating from the @catch directive. */
|
|
45
45
|
module CatchResult: {
|
|
46
46
|
/** The shape of an error caught via @catch. */
|
|
47
|
-
type catchError =
|
|
47
|
+
type catchError = JSON.t
|
|
48
48
|
|
|
49
49
|
/** The result type for @catch. */
|
|
50
50
|
@tag("ok")
|
|
@@ -89,10 +89,10 @@ Use it like this: `makeArguments({ "someArgument": someValue, "anotherArgument":
|
|
|
89
89
|
external makeArguments: {..} => arguments = "%identity"
|
|
90
90
|
|
|
91
91
|
/**Construct an `uploadables` object from a `Js.Dict` with your desired file format, that you can use for uploads via Relay.*/
|
|
92
|
-
external makeUploadables:
|
|
92
|
+
external makeUploadables: dict<'file> => uploadables = "%identity"
|
|
93
93
|
|
|
94
94
|
/**Unwraps `uploadables` into a Js.Dict.t with your expected file type, so you can use that dict to attach the provided files to your request.*/
|
|
95
|
-
external unwrapUploadables: uploadables =>
|
|
95
|
+
external unwrapUploadables: uploadables => dict<'file> = "%identity"
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
Generates a client-side `dataId` derived from an existing record.
|
|
@@ -196,7 +196,7 @@ external relayFeatureFlags: featureFlags = "RelayFeatureFlags"
|
|
|
196
196
|
/**Representing all records in the store serialized to JSON in a way that you can use to re-hydrate the store.
|
|
197
197
|
|
|
198
198
|
See `RecordSource.toJSON` for how to produce it.*/
|
|
199
|
-
type recordSourceRecords =
|
|
199
|
+
type recordSourceRecords = JSON.t
|
|
200
200
|
|
|
201
201
|
/**The `dataId` for the Relay store's root. Useful when for example referencing the `parentID` of a connection that's on the store root.*/
|
|
202
202
|
@module("relay-runtime")
|
|
@@ -208,7 +208,7 @@ external storeRootType: string = "ROOT_TYPE"
|
|
|
208
208
|
|
|
209
209
|
/**Internal, do not use.*/
|
|
210
210
|
@module("./utils")
|
|
211
|
-
external convertObj: ('a,
|
|
211
|
+
external convertObj: ('a, dict<dict<dict<string>>>, 'b, 'c) => 'd = "traverser"
|
|
212
212
|
|
|
213
213
|
/**Read the following section on working with the Relay store: https://relay.dev/docs/en/relay-store*/
|
|
214
214
|
module RecordProxy: {
|
|
@@ -279,8 +279,7 @@ module RecordProxy: {
|
|
|
279
279
|
)
|
|
280
280
|
```
|
|
281
281
|
*/
|
|
282
|
-
@send
|
|
283
|
-
@return(nullable)
|
|
282
|
+
@send @return(nullable)
|
|
284
283
|
external getLinkedRecord: (t, ~name: string, ~arguments: arguments=?) => option<t> =
|
|
285
284
|
"getLinkedRecord"
|
|
286
285
|
|
|
@@ -301,14 +300,12 @@ module RecordProxy: {
|
|
|
301
300
|
external getType: t => string = "getType"
|
|
302
301
|
|
|
303
302
|
/**Returns a field value, expecting it to be a string.*/
|
|
304
|
-
@send
|
|
305
|
-
@return(nullable)
|
|
303
|
+
@send @return(nullable)
|
|
306
304
|
external getValueString: (t, ~name: string, ~arguments: arguments=?) => option<string> =
|
|
307
305
|
"getValue"
|
|
308
306
|
|
|
309
307
|
/**Returns a field value, expecting it to be an array of strings.*/
|
|
310
|
-
@send
|
|
311
|
-
@return(nullable)
|
|
308
|
+
@send @return(nullable)
|
|
312
309
|
external getValueStringArray: (
|
|
313
310
|
t,
|
|
314
311
|
~name: string,
|
|
@@ -316,13 +313,11 @@ module RecordProxy: {
|
|
|
316
313
|
) => option<array<option<string>>> = "getValue"
|
|
317
314
|
|
|
318
315
|
/**Returns a field value, expecting it to be an int.*/
|
|
319
|
-
@send
|
|
320
|
-
@return(nullable)
|
|
316
|
+
@send @return(nullable)
|
|
321
317
|
external getValueInt: (t, ~name: string, ~arguments: arguments=?) => option<int> = "getValue"
|
|
322
318
|
|
|
323
319
|
/**Returns a field value, expecting it to be an array of ints.*/
|
|
324
|
-
@send
|
|
325
|
-
@return(nullable)
|
|
320
|
+
@send @return(nullable)
|
|
326
321
|
external getValueIntArray: (
|
|
327
322
|
t,
|
|
328
323
|
~name: string,
|
|
@@ -330,13 +325,11 @@ module RecordProxy: {
|
|
|
330
325
|
) => option<array<option<int>>> = "getValue"
|
|
331
326
|
|
|
332
327
|
/**Returns a field value, expecting it to be a float.*/
|
|
333
|
-
@send
|
|
334
|
-
@return(nullable)
|
|
328
|
+
@send @return(nullable)
|
|
335
329
|
external getValueFloat: (t, ~name: string, ~arguments: arguments=?) => option<float> = "getValue"
|
|
336
330
|
|
|
337
331
|
/**Returns a field value, expecting it to be an array of floats.*/
|
|
338
|
-
@send
|
|
339
|
-
@return(nullable)
|
|
332
|
+
@send @return(nullable)
|
|
340
333
|
external getValueFloatArray: (
|
|
341
334
|
t,
|
|
342
335
|
~name: string,
|
|
@@ -344,13 +337,11 @@ module RecordProxy: {
|
|
|
344
337
|
) => option<array<option<float>>> = "getValue"
|
|
345
338
|
|
|
346
339
|
/**Returns a field value, expecting it to be a boolean.*/
|
|
347
|
-
@send
|
|
348
|
-
@return(nullable)
|
|
340
|
+
@send @return(nullable)
|
|
349
341
|
external getValueBool: (t, ~name: string, ~arguments: arguments=?) => option<bool> = "getValue"
|
|
350
342
|
|
|
351
343
|
/**Returns a field value, expecting it to be an array of booleans.*/
|
|
352
|
-
@send
|
|
353
|
-
@return(nullable)
|
|
344
|
+
@send @return(nullable)
|
|
354
345
|
external getValueBoolArray: (
|
|
355
346
|
t,
|
|
356
347
|
~name: string,
|
|
@@ -604,8 +595,7 @@ module RecordSourceSelectorProxy: {
|
|
|
604
595
|
}
|
|
605
596
|
```
|
|
606
597
|
*/
|
|
607
|
-
@send
|
|
608
|
-
@return(nullable)
|
|
598
|
+
@send @return(nullable)
|
|
609
599
|
external get: (t, ~dataId: dataId) => option<RecordProxy.t> = "get"
|
|
610
600
|
|
|
611
601
|
/**Returns the _root_ `RecordProxy`, meaning the `RecordProxy` holding your top level fields.*/
|
|
@@ -613,8 +603,7 @@ module RecordSourceSelectorProxy: {
|
|
|
613
603
|
external getRoot: t => RecordProxy.t = "getRoot"
|
|
614
604
|
|
|
615
605
|
/**Returns the `RecordProxy` for the `fieldName` at root. You should prefer using `RecordSourceSelectorProxy.getRoot()` and traverse from there if you need access to root fields rather than use this.*/
|
|
616
|
-
@send
|
|
617
|
-
@return(nullable)
|
|
606
|
+
@send @return(nullable)
|
|
618
607
|
external getRootField: (t, ~fieldName: string) => option<RecordProxy.t> = "getRootField"
|
|
619
608
|
|
|
620
609
|
/**Plural version of `RecordSourceSelectorProxy.getRootField`.*/
|
|
@@ -634,8 +623,7 @@ module ReadOnlyRecordSourceProxy: {
|
|
|
634
623
|
type t
|
|
635
624
|
|
|
636
625
|
/**Returns the `RecordProxy` with the provided `dataId`, if it exists.*/
|
|
637
|
-
@send
|
|
638
|
-
@return(nullable)
|
|
626
|
+
@send @return(nullable)
|
|
639
627
|
external get: (t, ~dataId: dataId) => option<RecordProxy.t> = "get"
|
|
640
628
|
|
|
641
629
|
/**Returns the _root_ `RecordProxy`, meaning the `RecordProxy` holding your top level fields.*/
|
|
@@ -656,20 +644,20 @@ module MissingFieldHandler: {
|
|
|
656
644
|
|
|
657
645
|
type rec normalizationListValueArgument = {
|
|
658
646
|
name: string,
|
|
659
|
-
items: array<
|
|
647
|
+
items: array<Nullable.t<normalizationArgumentWrapped>>,
|
|
660
648
|
}
|
|
661
649
|
and normalizationLiteralArgument = {
|
|
662
650
|
name: string,
|
|
663
|
-
@as("type") type_:
|
|
664
|
-
value:
|
|
651
|
+
@as("type") type_: Nullable.t<string>,
|
|
652
|
+
value: JSON.t,
|
|
665
653
|
}
|
|
666
654
|
and normalizationObjectValueArgument = {
|
|
667
655
|
name: string,
|
|
668
|
-
fields:
|
|
656
|
+
fields: Nullable.t<array<normalizationArgumentWrapped>>,
|
|
669
657
|
}
|
|
670
658
|
and normalizationVariableArgument = {
|
|
671
659
|
name: string,
|
|
672
|
-
@as("type") type_:
|
|
660
|
+
@as("type") type_: Nullable.t<string>,
|
|
673
661
|
variableName: string,
|
|
674
662
|
}
|
|
675
663
|
|
|
@@ -682,50 +670,50 @@ module MissingFieldHandler: {
|
|
|
682
670
|
let unwrapNormalizationArgument: normalizationArgumentWrapped => normalizationArgument
|
|
683
671
|
|
|
684
672
|
type normalizationScalarField = {
|
|
685
|
-
alias:
|
|
673
|
+
alias: Nullable.t<string>,
|
|
686
674
|
name: string,
|
|
687
|
-
args:
|
|
688
|
-
storageKey:
|
|
675
|
+
args: Nullable.t<array<normalizationArgumentWrapped>>,
|
|
676
|
+
storageKey: Nullable.t<string>,
|
|
689
677
|
}
|
|
690
678
|
|
|
691
679
|
/**Make a `MissingFieldHandler.t` for scalar fields. Give this a handler function that returns `Js.null` (to indicate that data exists but is null), `Js.undefined` (to indicate data is still missing), or a scalar value (to indicate that the value exists even though it's not in the cache, and is the value you send back).*/
|
|
692
680
|
let makeScalarMissingFieldHandler: (
|
|
693
681
|
(
|
|
694
682
|
normalizationScalarField,
|
|
695
|
-
|
|
683
|
+
Nullable.t<'record>,
|
|
696
684
|
'args,
|
|
697
685
|
ReadOnlyRecordSourceProxy.t,
|
|
698
686
|
) => 'scalarValue
|
|
699
687
|
) => t
|
|
700
688
|
|
|
701
689
|
type normalizationLinkedField = {
|
|
702
|
-
alias:
|
|
690
|
+
alias: Nullable.t<string>,
|
|
703
691
|
name: string,
|
|
704
|
-
storageKey:
|
|
705
|
-
args:
|
|
706
|
-
concreteType:
|
|
692
|
+
storageKey: Nullable.t<string>,
|
|
693
|
+
args: Nullable.t<array<normalizationArgument>>,
|
|
694
|
+
concreteType: Nullable.t<string>,
|
|
707
695
|
plural: bool,
|
|
708
|
-
selections: array<
|
|
696
|
+
selections: array<JSON.t>,
|
|
709
697
|
}
|
|
710
698
|
|
|
711
699
|
/**Make a `MissingFieldHandler.t` for linked fields (other objects/records). Give this a handler function that returns `Js.null` (to indicate that the link exists but the linked record is null), `Js.undefined` (to indicate data is still missing), or a `dataId` of the record that is linked at this field.*/
|
|
712
700
|
let makeLinkedMissingFieldHandler: (
|
|
713
701
|
(
|
|
714
702
|
normalizationLinkedField,
|
|
715
|
-
|
|
703
|
+
Nullable.t<RecordProxy.t>,
|
|
716
704
|
'args,
|
|
717
705
|
ReadOnlyRecordSourceProxy.t,
|
|
718
|
-
) =>
|
|
706
|
+
) => Nullable.t<dataId>
|
|
719
707
|
) => t
|
|
720
708
|
|
|
721
709
|
/**Make a `MissingFieldHandler.t` for lists of linked fields (other objects/records). Give this a handler function that returns `Js.null` (to indicate that the link exists but the linked record is null), `Js.undefined` (to indicate data is still missing), or an array of `Js.Nullable.t<dataId>` where the `dataId`'s are the linked records/objects.*/
|
|
722
710
|
let makePluralLinkedMissingFieldHandler: (
|
|
723
711
|
(
|
|
724
712
|
normalizationLinkedField,
|
|
725
|
-
|
|
713
|
+
Nullable.t<RecordProxy.t>,
|
|
726
714
|
'args,
|
|
727
715
|
ReadOnlyRecordSourceProxy.t,
|
|
728
|
-
) =>
|
|
716
|
+
) => Nullable.t<array<Nullable.t<dataId>>>
|
|
729
717
|
) => t
|
|
730
718
|
}
|
|
731
719
|
|
|
@@ -760,9 +748,7 @@ module ConnectionHandler: {
|
|
|
760
748
|
)
|
|
761
749
|
```
|
|
762
750
|
*/
|
|
763
|
-
@module("relay-runtime")
|
|
764
|
-
@scope("ConnectionHandler")
|
|
765
|
-
@return(nullable)
|
|
751
|
+
@module("relay-runtime") @scope("ConnectionHandler") @return(nullable)
|
|
766
752
|
external getConnection: (
|
|
767
753
|
~record: RecordProxy.t,
|
|
768
754
|
~key: string,
|
|
@@ -795,8 +781,7 @@ module ConnectionHandler: {
|
|
|
795
781
|
)
|
|
796
782
|
```
|
|
797
783
|
*/
|
|
798
|
-
@module("relay-runtime")
|
|
799
|
-
@scope("ConnectionHandler")
|
|
784
|
+
@module("relay-runtime") @scope("ConnectionHandler")
|
|
800
785
|
external createEdge: (
|
|
801
786
|
~store: RecordSourceSelectorProxy.t,
|
|
802
787
|
~connection: RecordProxy.t,
|
|
@@ -834,8 +819,7 @@ module ConnectionHandler: {
|
|
|
834
819
|
)
|
|
835
820
|
```
|
|
836
821
|
*/
|
|
837
|
-
@module("relay-runtime")
|
|
838
|
-
@scope("ConnectionHandler")
|
|
822
|
+
@module("relay-runtime") @scope("ConnectionHandler")
|
|
839
823
|
external insertEdgeBefore: (
|
|
840
824
|
~connection: RecordProxy.t,
|
|
841
825
|
~newEdge: RecordProxy.t,
|
|
@@ -865,8 +849,7 @@ module ConnectionHandler: {
|
|
|
865
849
|
)
|
|
866
850
|
```
|
|
867
851
|
*/
|
|
868
|
-
@module("relay-runtime")
|
|
869
|
-
@scope("ConnectionHandler")
|
|
852
|
+
@module("relay-runtime") @scope("ConnectionHandler")
|
|
870
853
|
external insertEdgeAfter: (
|
|
871
854
|
~connection: RecordProxy.t,
|
|
872
855
|
~newEdge: RecordProxy.t,
|
|
@@ -895,8 +878,7 @@ module ConnectionHandler: {
|
|
|
895
878
|
)
|
|
896
879
|
```
|
|
897
880
|
*/
|
|
898
|
-
@module("relay-runtime")
|
|
899
|
-
@scope("ConnectionHandler")
|
|
881
|
+
@module("relay-runtime") @scope("ConnectionHandler")
|
|
900
882
|
external deleteNode: (~connection: RecordProxy.t, ~nodeId: dataId) => unit = "deleteNode"
|
|
901
883
|
|
|
902
884
|
/**
|
|
@@ -926,8 +908,7 @@ module ConnectionHandler: {
|
|
|
926
908
|
let connectionId = UserPosts_user_graphql.getConnectionId(~status=PUBLISHED)
|
|
927
909
|
```
|
|
928
910
|
*/
|
|
929
|
-
@module("relay-runtime")
|
|
930
|
-
@scope("ConnectionHandler")
|
|
911
|
+
@module("relay-runtime") @scope("ConnectionHandler")
|
|
931
912
|
external getConnectionID: (dataId, string, 'filters) => dataId = "getConnectionID"
|
|
932
913
|
}
|
|
933
914
|
|
|
@@ -947,7 +928,7 @@ module Observable: {
|
|
|
947
928
|
/**This sink can be used to give the observable new data.*/
|
|
948
929
|
type sink<'response> = {
|
|
949
930
|
next: 'response => unit,
|
|
950
|
-
error:
|
|
931
|
+
error: JsExn.t => unit,
|
|
951
932
|
complete: unit => unit,
|
|
952
933
|
closed: bool,
|
|
953
934
|
}
|
|
@@ -966,14 +947,13 @@ module Observable: {
|
|
|
966
947
|
external makeObserver: (
|
|
967
948
|
~start: subscription => unit=?,
|
|
968
949
|
~next: 'response => unit=?,
|
|
969
|
-
~error:
|
|
950
|
+
~error: JsExn.t => unit=?,
|
|
970
951
|
~complete: unit => unit=?,
|
|
971
952
|
~unsubscribe: subscription => unit=?,
|
|
972
953
|
) => observer<'response> = ""
|
|
973
954
|
|
|
974
955
|
/**Create a new observable, getting fed an `Observable.sink` for interacting with the observable, and optionally returning a `Observable.subscription` if you have things you want to unsubscribe from as the observable closes.*/
|
|
975
|
-
@module("relay-runtime")
|
|
976
|
-
@scope("Observable")
|
|
956
|
+
@module("relay-runtime") @scope("Observable")
|
|
977
957
|
external make: (sink<'t> => option<subscription>) => t<'t> = "create"
|
|
978
958
|
|
|
979
959
|
/**Subscribe to the `Observable.t` using an observer.*/
|
|
@@ -982,9 +962,10 @@ module Observable: {
|
|
|
982
962
|
|
|
983
963
|
/**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.*/
|
|
984
964
|
@send
|
|
985
|
-
external toPromise: t<'t> =>
|
|
965
|
+
external toPromise: t<'t> => promise<'t> = "toPromise"
|
|
986
966
|
|
|
987
|
-
/**Ignore this subscription.*/
|
|
967
|
+
/**Ignore this subscription.*/
|
|
968
|
+
external ignoreSubscription: subscription => unit = "%ignore"
|
|
988
969
|
}
|
|
989
970
|
|
|
990
971
|
/**
|
|
@@ -1018,15 +999,15 @@ module Network: {
|
|
|
1018
999
|
*/
|
|
1019
1000
|
type operation = {
|
|
1020
1001
|
/** The operation ID. Set if persisted queries are enabled, otherwise not set. */
|
|
1021
|
-
id:
|
|
1002
|
+
id: Nullable.t<string>,
|
|
1022
1003
|
/** The operation text. Not set for persisted queries, or if this is a client-only query that will not make a network request. */
|
|
1023
|
-
text:
|
|
1004
|
+
text: Nullable.t<string>,
|
|
1024
1005
|
/** The operation name. */
|
|
1025
1006
|
name: string,
|
|
1026
1007
|
/** The operation kind. */
|
|
1027
1008
|
operationKind: string,
|
|
1028
1009
|
/** Optional operation metadata. */
|
|
1029
|
-
metadata:
|
|
1010
|
+
metadata: Nullable.t<operationMetadata>,
|
|
1030
1011
|
}
|
|
1031
1012
|
|
|
1032
1013
|
/**
|
|
@@ -1040,7 +1021,7 @@ module Network: {
|
|
|
1040
1021
|
## Returns
|
|
1041
1022
|
Observable that emits subscription data over time
|
|
1042
1023
|
*/
|
|
1043
|
-
type subscribeFn = (operation,
|
|
1024
|
+
type subscribeFn = (operation, JSON.t, cacheConfig) => Observable.t<JSON.t>
|
|
1044
1025
|
|
|
1045
1026
|
/**
|
|
1046
1027
|
Function signature for fetching data using promises.
|
|
@@ -1056,10 +1037,10 @@ module Network: {
|
|
|
1056
1037
|
*/
|
|
1057
1038
|
type fetchFunctionPromise = (
|
|
1058
1039
|
operation,
|
|
1059
|
-
|
|
1040
|
+
JSON.t,
|
|
1060
1041
|
cacheConfig,
|
|
1061
|
-
|
|
1062
|
-
) =>
|
|
1042
|
+
Nullable.t<uploadables>,
|
|
1043
|
+
) => promise<JSON.t>
|
|
1063
1044
|
|
|
1064
1045
|
/**
|
|
1065
1046
|
Function signature for fetching data using observables.
|
|
@@ -1075,10 +1056,10 @@ module Network: {
|
|
|
1075
1056
|
*/
|
|
1076
1057
|
type fetchFunctionObservable = (
|
|
1077
1058
|
operation,
|
|
1078
|
-
|
|
1059
|
+
JSON.t,
|
|
1079
1060
|
cacheConfig,
|
|
1080
|
-
|
|
1081
|
-
) => Observable.t<
|
|
1061
|
+
Nullable.t<uploadables>,
|
|
1062
|
+
) => Observable.t<JSON.t>
|
|
1082
1063
|
|
|
1083
1064
|
/**
|
|
1084
1065
|
Creates a network layer using a promise-based fetch function.
|
|
@@ -1090,8 +1071,7 @@ module Network: {
|
|
|
1090
1071
|
- `fetchFunction`: Function that returns promises for GraphQL requests
|
|
1091
1072
|
- `subscriptionFunction`: Optional function for handling subscriptions
|
|
1092
1073
|
*/
|
|
1093
|
-
@module("relay-runtime")
|
|
1094
|
-
@scope("Network")
|
|
1074
|
+
@module("relay-runtime") @scope("Network")
|
|
1095
1075
|
external makePromiseBased: (
|
|
1096
1076
|
~fetchFunction: fetchFunctionPromise,
|
|
1097
1077
|
~subscriptionFunction: subscribeFn=?,
|
|
@@ -1107,8 +1087,7 @@ module Network: {
|
|
|
1107
1087
|
- `observableFunction`: Function that returns observables for GraphQL requests
|
|
1108
1088
|
- `subscriptionFunction`: Optional function for handling subscriptions
|
|
1109
1089
|
*/
|
|
1110
|
-
@module("relay-runtime")
|
|
1111
|
-
@scope("Network")
|
|
1090
|
+
@module("relay-runtime") @scope("Network")
|
|
1112
1091
|
external makeObservableBased: (
|
|
1113
1092
|
~observableFunction: fetchFunctionObservable,
|
|
1114
1093
|
~subscriptionFunction: subscribeFn=?,
|
|
@@ -1120,7 +1099,7 @@ module Network: {
|
|
|
1120
1099
|
Internal function for resource preloading. Used by Relay's code splitting
|
|
1121
1100
|
and resource preloading features.
|
|
1122
1101
|
*/
|
|
1123
|
-
let preloadResources: (~operation: operation, ~variables:
|
|
1102
|
+
let preloadResources: (~operation: operation, ~variables: JSON.t, ~response: JSON.t) => unit
|
|
1124
1103
|
}
|
|
1125
1104
|
|
|
1126
1105
|
/**
|
|
@@ -1156,8 +1135,7 @@ module RecordSource: {
|
|
|
1156
1135
|
)
|
|
1157
1136
|
```
|
|
1158
1137
|
*/
|
|
1159
|
-
@module("relay-runtime")
|
|
1160
|
-
@new
|
|
1138
|
+
@module("relay-runtime") @new
|
|
1161
1139
|
external make: (~records: recordSourceRecords=?) => t = "RecordSource"
|
|
1162
1140
|
|
|
1163
1141
|
/**
|
|
@@ -1324,7 +1302,8 @@ module Disposable: {
|
|
|
1324
1302
|
@send
|
|
1325
1303
|
external dispose: t => unit = "dispose"
|
|
1326
1304
|
|
|
1327
|
-
/**Ignore this disposable.*/
|
|
1305
|
+
/**Ignore this disposable.*/
|
|
1306
|
+
external ignore: t => unit = "%ignore"
|
|
1328
1307
|
}
|
|
1329
1308
|
|
|
1330
1309
|
/**A required field logger, which gets called when a field annotated with the @required directive was missing from the response*/
|
|
@@ -1335,33 +1314,33 @@ module RelayFieldLogger: {
|
|
|
1335
1314
|
MissingRequiredFieldLog({
|
|
1336
1315
|
owner: string,
|
|
1337
1316
|
fieldPath: string,
|
|
1338
|
-
uiContext: option<
|
|
1317
|
+
uiContext: option<JSON.t>,
|
|
1339
1318
|
})
|
|
1340
1319
|
| @as("missing_required_field.throw")
|
|
1341
1320
|
MissingRequiredFieldThrow({
|
|
1342
1321
|
owner: string,
|
|
1343
1322
|
fieldPath: string,
|
|
1344
|
-
uiContext: option<
|
|
1323
|
+
uiContext: option<JSON.t>,
|
|
1345
1324
|
})
|
|
1346
1325
|
| @as("missing_expected_data.log")
|
|
1347
1326
|
MissingExpectedData({
|
|
1348
1327
|
owner: string,
|
|
1349
1328
|
fieldPath: string,
|
|
1350
|
-
uiContext: option<
|
|
1329
|
+
uiContext: option<JSON.t>,
|
|
1351
1330
|
})
|
|
1352
1331
|
| @as("missing_expected_data.throw")
|
|
1353
1332
|
MissingExpectedDataThrow({
|
|
1354
1333
|
owner: string,
|
|
1355
1334
|
fieldPath: string,
|
|
1356
1335
|
handled: bool,
|
|
1357
|
-
uiContext: option<
|
|
1336
|
+
uiContext: option<JSON.t>,
|
|
1358
1337
|
})
|
|
1359
1338
|
| @as("relay_resolver.error")
|
|
1360
1339
|
RelayResolverError({
|
|
1361
1340
|
owner: string,
|
|
1362
1341
|
fieldPath: string,
|
|
1363
|
-
error:
|
|
1364
|
-
uiContext: option<
|
|
1342
|
+
error: JsExn.t,
|
|
1343
|
+
uiContext: option<JSON.t>,
|
|
1365
1344
|
})
|
|
1366
1345
|
|
|
1367
1346
|
/**A required field logger, which gets called when a field annotated with the @required directive was missing from the response*/
|
|
@@ -1536,27 +1515,21 @@ module Environment: {
|
|
|
1536
1515
|
|
|
1537
1516
|
/**fetchPolicy controls how you want Relay to resolve your data.*/
|
|
1538
1517
|
type fetchPolicy =
|
|
1539
|
-
|
|
1540
|
-
@as("store-only")
|
|
1541
|
-
|
|
1542
|
-
|
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
@as("
|
|
1547
|
-
StoreAndNetwork
|
|
1548
|
-
| /** will not reuse locally cached data, and will always send a network request to fetch the query, ignoring any data that might be locally cached and whether it's missing or stale. */
|
|
1549
|
-
@as("network-only")
|
|
1550
|
-
NetworkOnly
|
|
1518
|
+
/** will only reuse locally cached data, and will never send a network request to fetch the query. In this case, the responsibility of fetching the query falls to the caller, but this policy could also be used to read and operate on data that is entirely local. */
|
|
1519
|
+
| @as("store-only") StoreOnly
|
|
1520
|
+
/** (default) will reuse locally cached data, and will only send a network request if any data for the query is missing or stale. If the query is fully cached, a network request will not be made.*/
|
|
1521
|
+
| @as("store-or-network") StoreOrNetwork
|
|
1522
|
+
/** will reuse locally cached data and will always send a network request, regardless of whether any data was missing or stale in the store. */
|
|
1523
|
+
| @as("store-and-network") StoreAndNetwork
|
|
1524
|
+
/** will not reuse locally cached data, and will always send a network request to fetch the query, ignoring any data that might be locally cached and whether it's missing or stale. */
|
|
1525
|
+
| @as("network-only") NetworkOnly
|
|
1551
1526
|
|
|
1552
1527
|
/**The fetch policies allowed for fetching a query outside of React's render (as in `Query.fetch`).*/
|
|
1553
1528
|
type fetchQueryFetchPolicy =
|
|
1554
|
-
|
|
1555
|
-
@as("network-only")
|
|
1556
|
-
|
|
1557
|
-
|
|
|
1558
|
-
@as("store-or-network")
|
|
1559
|
-
StoreOrNetwork
|
|
1529
|
+
/** will not reuse locally cached data, and will always send a network request to fetch the query, ignoring any data that might be locally cached and whether it's missing or stale. */
|
|
1530
|
+
| @as("network-only") NetworkOnly
|
|
1531
|
+
/** (default) will reuse locally cached data, and will only send a network request if any data for the query is missing or stale. If the query is fully cached, a network request will not be made.*/
|
|
1532
|
+
| @as("store-or-network") StoreOrNetwork
|
|
1560
1533
|
|
|
1561
1534
|
/**An error from a mutation.*/
|
|
1562
1535
|
type mutationError = {message: string}
|
|
@@ -1590,7 +1563,8 @@ exception EnvironmentNotFoundInContext
|
|
|
1590
1563
|
/**Hook for getting the current environment from context.*/
|
|
1591
1564
|
let useEnvironmentFromContext: unit => Environment.t
|
|
1592
1565
|
|
|
1593
|
-
/**An exception detailing that a mutation failed.*/
|
|
1566
|
+
/**An exception detailing that a mutation failed.*/
|
|
1567
|
+
exception Mutation_failed(array<mutationError>)
|
|
1594
1568
|
|
|
1595
1569
|
/**
|
|
1596
1570
|
Commits a local update to the Relay store.
|
|
@@ -1698,5 +1672,5 @@ module MakeLoadQuery: (C: MakeLoadQueryConfig) =>
|
|
|
1698
1672
|
) => C.loadedQueryRef
|
|
1699
1673
|
|
|
1700
1674
|
let queryRefToObservable: C.loadedQueryRef => option<Observable.t<C.response>>
|
|
1701
|
-
let queryRefToPromise: C.loadedQueryRef =>
|
|
1675
|
+
let queryRefToPromise: C.loadedQueryRef => promise<Belt.Result.t<unit, unit>>
|
|
1702
1676
|
}
|
|
@@ -1,72 +1,69 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var RelayRuntime = require("relay-runtime");
|
|
4
|
+
let Stdlib_List = require("@rescript/runtime/lib/js/Stdlib_List.js");
|
|
5
|
+
let RelayRuntime = require("relay-runtime");
|
|
6
|
+
let Primitive_option = require("@rescript/runtime/lib/js/Primitive_option.js");
|
|
8
7
|
|
|
9
8
|
function resolveNestedRecord(rootRecord, path) {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
let currentRecord = rootRecord;
|
|
10
|
+
let pathLength = Stdlib_List.length(path);
|
|
12
11
|
if (pathLength !== 0) {
|
|
13
|
-
for(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
currentRecord = match !== undefined && currentPath !== undefined ?
|
|
12
|
+
for (let i = 0; i < pathLength; ++i) {
|
|
13
|
+
let currentPath = Stdlib_List.get(path, i);
|
|
14
|
+
let match = currentRecord;
|
|
15
|
+
currentRecord = match !== undefined && currentPath !== undefined ? Primitive_option.fromNullable(Primitive_option.valFromOption(match).getLinkedRecord(currentPath)) : undefined;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
return currentRecord;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
function resolveNestedRecordFromRoot(store, path) {
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
22
|
+
if (path === 0) {
|
|
23
|
+
return;
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (restPath) {
|
|
29
|
-
return resolveNestedRecord(
|
|
25
|
+
let restPath = path.tl;
|
|
26
|
+
let rootRecordPath = path.hd;
|
|
27
|
+
if (restPath !== 0) {
|
|
28
|
+
return resolveNestedRecord(Primitive_option.fromNullable(store.getRootField(rootRecordPath)), restPath);
|
|
30
29
|
}
|
|
31
|
-
|
|
30
|
+
let rootRecord = store.getRootField(rootRecordPath);
|
|
32
31
|
if (!(rootRecord == null)) {
|
|
33
|
-
return
|
|
32
|
+
return Primitive_option.some(rootRecord);
|
|
34
33
|
}
|
|
35
|
-
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
function removeNodeFromConnections(store, node, connections) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}));
|
|
37
|
+
Stdlib_List.forEach(connections, connectionConfig => {
|
|
38
|
+
let owner = store.get(connectionConfig.parentID);
|
|
39
|
+
if (owner == null) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let connection = RelayRuntime.ConnectionHandler.getConnection(owner, connectionConfig.key, connectionConfig.filters !== undefined ? Primitive_option.valFromOption(connectionConfig.filters) : undefined);
|
|
43
|
+
if (!(connection == null)) {
|
|
44
|
+
RelayRuntime.ConnectionHandler.deleteNode(connection, node.getDataID());
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
function createAndAddEdgeToConnections(store, node, connections, edgeName, insertAt) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
51
|
+
Stdlib_List.forEach(connections, connectionConfig => {
|
|
52
|
+
let connectionOwner = store.get(connectionConfig.parentID);
|
|
53
|
+
if (connectionOwner == null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let connection = RelayRuntime.ConnectionHandler.getConnection(connectionOwner, connectionConfig.key, connectionConfig.filters !== undefined ? Primitive_option.valFromOption(connectionConfig.filters) : undefined);
|
|
57
|
+
if (connection == null) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let edge = RelayRuntime.ConnectionHandler.createEdge(store, connection, node, edgeName);
|
|
61
|
+
if (insertAt === "Start") {
|
|
62
|
+
RelayRuntime.ConnectionHandler.insertEdgeAfter(connection, edge);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
RelayRuntime.ConnectionHandler.insertEdgeBefore(connection, edge);
|
|
66
|
+
});
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
exports.resolveNestedRecord = resolveNestedRecord;
|
|
@@ -11,7 +11,7 @@ let resolveNestedRecord = (
|
|
|
11
11
|
| 0 => ()
|
|
12
12
|
| _ =>
|
|
13
13
|
for i in 0 to pathLength - 1 {
|
|
14
|
-
let currentPath = path->
|
|
14
|
+
let currentPath = path->List.get(i)
|
|
15
15
|
switch (currentRecord.contents, currentPath) {
|
|
16
16
|
| (Some(record), Some(currentPath)) =>
|
|
17
17
|
currentRecord := record->RescriptRelay.RecordProxy.getLinkedRecord(~name=currentPath)
|
|
@@ -51,7 +51,7 @@ type connectionConfig = {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
let removeNodeFromConnections = (~store, ~node, ~connections) =>
|
|
54
|
-
connections->
|
|
54
|
+
connections->List.forEach(connectionConfig =>
|
|
55
55
|
switch store->RecordSourceSelectorProxy.get(~dataId=connectionConfig.parentID) {
|
|
56
56
|
| Some(owner) =>
|
|
57
57
|
switch ConnectionHandler.getConnection(
|
|
@@ -68,7 +68,7 @@ let removeNodeFromConnections = (~store, ~node, ~connections) =>
|
|
|
68
68
|
)
|
|
69
69
|
|
|
70
70
|
let createAndAddEdgeToConnections = (~store, ~node, ~connections, ~edgeName, ~insertAt) =>
|
|
71
|
-
connections->
|
|
71
|
+
connections->List.forEach(connectionConfig =>
|
|
72
72
|
switch store->RecordSourceSelectorProxy.get(~dataId=connectionConfig.parentID) {
|
|
73
73
|
| Some(connectionOwner) =>
|
|
74
74
|
switch ConnectionHandler.getConnection(
|