rescript-relay 4.1.0 → 4.2.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 +6 -0
- package/package.json +1 -1
- 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 +12 -35
- package/src/RescriptRelay.res +51 -64
- package/src/RescriptRelay.resi +55 -48
- package/src/RescriptRelay_Internal.bs.js +4 -4
- package/src/RescriptRelay_Internal.res +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
+
# 4.2.0
|
|
4
|
+
|
|
5
|
+
- Simplify `missingFieldHandlers`. https://github.com/zth/rescript-relay/pull/589
|
|
6
|
+
- Fix behavior of `refetchVariables` on optional variables. https://github.com/zth/rescript-relay/pull/588
|
|
7
|
+
- Support `@exhaustive` on inline fragments.
|
|
8
|
+
|
|
3
9
|
# 4.1.0
|
|
4
10
|
|
|
5
11
|
- Add support for `autoExhaustiveTypes` config and a `@nonExhaustive` directive to control automatic exhaustive checks for unions/interfaces.
|
package/package.json
CHANGED
package/ppx-macos-arm64
CHANGED
|
Binary file
|
package/ppx-macos-latest
CHANGED
|
Binary file
|
package/ppx-windows-latest
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/RescriptRelay.bs.js
CHANGED
|
@@ -77,31 +77,6 @@ let RecordSourceSelectorProxy = {
|
|
|
77
77
|
|
|
78
78
|
let ReadOnlyRecordSourceProxy = {};
|
|
79
79
|
|
|
80
|
-
function unwrapNormalizationArgument(wrapped) {
|
|
81
|
-
let match = wrapped.kind;
|
|
82
|
-
if (match === "Literal") {
|
|
83
|
-
return {
|
|
84
|
-
TAG: "Literal",
|
|
85
|
-
_0: wrapped
|
|
86
|
-
};
|
|
87
|
-
} else if (match === "ListValue") {
|
|
88
|
-
return {
|
|
89
|
-
TAG: "ListValue",
|
|
90
|
-
_0: wrapped
|
|
91
|
-
};
|
|
92
|
-
} else if (match === "ObjectValue") {
|
|
93
|
-
return {
|
|
94
|
-
TAG: "ObjectValue",
|
|
95
|
-
_0: wrapped
|
|
96
|
-
};
|
|
97
|
-
} else {
|
|
98
|
-
return {
|
|
99
|
-
TAG: "Variable",
|
|
100
|
-
_0: wrapped
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
80
|
function makeScalarMissingFieldHandler(handle) {
|
|
106
81
|
return {
|
|
107
82
|
kind: "scalar",
|
|
@@ -124,21 +99,23 @@ function makePluralLinkedMissingFieldHandler(handle) {
|
|
|
124
99
|
}
|
|
125
100
|
|
|
126
101
|
let MissingFieldHandler = {
|
|
127
|
-
unwrapNormalizationArgument: unwrapNormalizationArgument,
|
|
128
102
|
makeScalarMissingFieldHandler: makeScalarMissingFieldHandler,
|
|
129
103
|
makeLinkedMissingFieldHandler: makeLinkedMissingFieldHandler,
|
|
130
104
|
makePluralLinkedMissingFieldHandler: makePluralLinkedMissingFieldHandler
|
|
131
105
|
};
|
|
132
106
|
|
|
133
|
-
let nodeInterfaceMissingFieldHandler =
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
107
|
+
let nodeInterfaceMissingFieldHandler = {
|
|
108
|
+
kind: "linked",
|
|
109
|
+
handle: (field, record, args, _store) => {
|
|
110
|
+
let match = field.name;
|
|
111
|
+
let match$1 = args.id;
|
|
112
|
+
if ((record == null) || match !== "node" || record.getType() !== RelayRuntime.ROOT_TYPE) {
|
|
113
|
+
return;
|
|
114
|
+
} else {
|
|
115
|
+
return match$1;
|
|
116
|
+
}
|
|
140
117
|
}
|
|
141
|
-
}
|
|
118
|
+
};
|
|
142
119
|
|
|
143
120
|
let ConnectionHandler = {};
|
|
144
121
|
|
|
@@ -311,4 +288,4 @@ exports.Disposable = Disposable;
|
|
|
311
288
|
exports.RelayFieldLogger = RelayFieldLogger;
|
|
312
289
|
exports.Environment = Environment;
|
|
313
290
|
exports.Mutation_failed = Mutation_failed;
|
|
314
|
-
/*
|
|
291
|
+
/* ./utils Not a pure module */
|
package/src/RescriptRelay.res
CHANGED
|
@@ -347,78 +347,65 @@ module ReadOnlyRecordSourceProxy = {
|
|
|
347
347
|
}
|
|
348
348
|
|
|
349
349
|
module MissingFieldHandler = {
|
|
350
|
-
|
|
351
|
-
type
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
name: string,
|
|
357
|
-
items: array<Nullable.t<normalizationArgumentWrapped>>,
|
|
358
|
-
}
|
|
359
|
-
and normalizationLiteralArgument = {
|
|
360
|
-
name: string,
|
|
361
|
-
@as("type") type_: Nullable.t<string>,
|
|
362
|
-
value: JSON.t,
|
|
363
|
-
}
|
|
364
|
-
and normalizationObjectValueArgument = {
|
|
365
|
-
name: string,
|
|
366
|
-
fields: Nullable.t<array<normalizationArgumentWrapped>>,
|
|
367
|
-
}
|
|
368
|
-
and normalizationVariableArgument = {
|
|
369
|
-
name: string,
|
|
370
|
-
@as("type") type_: Nullable.t<string>,
|
|
371
|
-
variableName: string,
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
type normalizationArgument =
|
|
375
|
-
| ListValue(normalizationListValueArgument)
|
|
376
|
-
| Literal(normalizationLiteralArgument)
|
|
377
|
-
| ObjectValue(normalizationObjectValueArgument)
|
|
378
|
-
| Variable(normalizationVariableArgument)
|
|
379
|
-
|
|
380
|
-
let unwrapNormalizationArgument = wrapped =>
|
|
381
|
-
switch wrapped.kind {
|
|
382
|
-
| #ListValue => ListValue(Obj.magic(wrapped))
|
|
383
|
-
| #Literal => Literal(Obj.magic(wrapped))
|
|
384
|
-
| #ObjectValue => ObjectValue(Obj.magic(wrapped))
|
|
385
|
-
| #Variable => Variable(Obj.magic(wrapped))
|
|
386
|
-
}
|
|
350
|
+
@tag("kind")
|
|
351
|
+
type rec normalizationArgument =
|
|
352
|
+
| ListValue({name: string, items: array<null<normalizationArgument>>})
|
|
353
|
+
| Literal({name: string, @as("type") type_: nullable<string>, value: JSON.t})
|
|
354
|
+
| ObjectValue({name: string, fields: array<normalizationArgument>})
|
|
355
|
+
| Variable({name: string, @as("type") type_: nullable<string>, variableName: string})
|
|
387
356
|
|
|
388
357
|
type normalizationScalarField = {
|
|
389
|
-
alias:
|
|
358
|
+
alias: nullable<string>,
|
|
390
359
|
name: string,
|
|
391
|
-
args:
|
|
392
|
-
storageKey:
|
|
360
|
+
args: nullable<array<normalizationArgument>>,
|
|
361
|
+
storageKey: nullable<string>,
|
|
393
362
|
}
|
|
394
363
|
|
|
395
|
-
let makeScalarMissingFieldHandler = handle =>
|
|
396
|
-
Obj.magic({
|
|
397
|
-
"kind": #scalar,
|
|
398
|
-
"handle": handle,
|
|
399
|
-
})
|
|
400
|
-
|
|
401
364
|
type normalizationLinkedField = {
|
|
402
|
-
alias:
|
|
365
|
+
alias: nullable<string>,
|
|
403
366
|
name: string,
|
|
404
|
-
storageKey:
|
|
405
|
-
args:
|
|
406
|
-
concreteType:
|
|
367
|
+
storageKey: nullable<string>,
|
|
368
|
+
args: nullable<array<normalizationArgument>>,
|
|
369
|
+
concreteType: nullable<string>,
|
|
407
370
|
plural: bool,
|
|
408
371
|
selections: array<JSON.t>,
|
|
409
372
|
}
|
|
410
373
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
374
|
+
@tag("kind")
|
|
375
|
+
type rec t =
|
|
376
|
+
| @as("scalar")
|
|
377
|
+
Scalar({
|
|
378
|
+
handle: (
|
|
379
|
+
normalizationScalarField,
|
|
380
|
+
nullable<'record>,
|
|
381
|
+
'args,
|
|
382
|
+
ReadOnlyRecordSourceProxy.t,
|
|
383
|
+
) => nullable<'scalarValue>,
|
|
384
|
+
}): t
|
|
385
|
+
| @as("linked")
|
|
386
|
+
Linked({
|
|
387
|
+
handle: (
|
|
388
|
+
normalizationLinkedField,
|
|
389
|
+
nullable<'record>,
|
|
390
|
+
'args,
|
|
391
|
+
ReadOnlyRecordSourceProxy.t,
|
|
392
|
+
) => nullable<dataId>,
|
|
393
|
+
}): t
|
|
394
|
+
| @as("pluralLinked")
|
|
395
|
+
PluralLinked({
|
|
396
|
+
handle: (
|
|
397
|
+
normalizationLinkedField,
|
|
398
|
+
nullable<'record>,
|
|
399
|
+
'args,
|
|
400
|
+
ReadOnlyRecordSourceProxy.t,
|
|
401
|
+
) => nullable<array<nullable<dataId>>>,
|
|
402
|
+
}): t
|
|
403
|
+
|
|
404
|
+
let makeScalarMissingFieldHandler = handle => Scalar({handle: handle})
|
|
405
|
+
|
|
406
|
+
let makeLinkedMissingFieldHandler = handle => Linked({handle: handle})
|
|
407
|
+
|
|
408
|
+
let makePluralLinkedMissingFieldHandler = handle => PluralLinked({handle: handle})
|
|
422
409
|
}
|
|
423
410
|
|
|
424
411
|
// This handler below enables automatic resolution of all cached items through the Node interface
|
|
@@ -428,9 +415,9 @@ let nodeInterfaceMissingFieldHandler = MissingFieldHandler.makeLinkedMissingFiel
|
|
|
428
415
|
args,
|
|
429
416
|
_store,
|
|
430
417
|
) =>
|
|
431
|
-
switch (
|
|
432
|
-
| (
|
|
433
|
-
| _ =>
|
|
418
|
+
switch (record, field.name, args["id"]) {
|
|
419
|
+
| (Value(record), "node", argsId) if record->RecordProxy.getType == storeRootType => argsId
|
|
420
|
+
| _ => undefined
|
|
434
421
|
}
|
|
435
422
|
)
|
|
436
423
|
|
package/src/RescriptRelay.resi
CHANGED
|
@@ -635,68 +635,75 @@ module ReadOnlyRecordSourceProxy: {
|
|
|
635
635
|
|
|
636
636
|
Feed a list of missing field handlers into `Environment.make` if you want to use them.*/
|
|
637
637
|
module MissingFieldHandler: {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
638
|
+
@tag("kind")
|
|
639
|
+
type rec normalizationArgument =
|
|
640
|
+
| ListValue({name: string, items: array<null<normalizationArgument>>})
|
|
641
|
+
| Literal({name: string, @as("type") type_: nullable<string>, value: JSON.t})
|
|
642
|
+
| ObjectValue({name: string, fields: array<normalizationArgument>})
|
|
643
|
+
| Variable({name: string, @as("type") type_: nullable<string>, variableName: string})
|
|
644
644
|
|
|
645
|
-
type
|
|
646
|
-
|
|
647
|
-
items: array<Nullable.t<normalizationArgumentWrapped>>,
|
|
648
|
-
}
|
|
649
|
-
and normalizationLiteralArgument = {
|
|
650
|
-
name: string,
|
|
651
|
-
@as("type") type_: Nullable.t<string>,
|
|
652
|
-
value: JSON.t,
|
|
653
|
-
}
|
|
654
|
-
and normalizationObjectValueArgument = {
|
|
655
|
-
name: string,
|
|
656
|
-
fields: Nullable.t<array<normalizationArgumentWrapped>>,
|
|
657
|
-
}
|
|
658
|
-
and normalizationVariableArgument = {
|
|
645
|
+
type normalizationScalarField = {
|
|
646
|
+
alias: nullable<string>,
|
|
659
647
|
name: string,
|
|
660
|
-
|
|
661
|
-
|
|
648
|
+
args: nullable<array<normalizationArgument>>,
|
|
649
|
+
storageKey: nullable<string>,
|
|
662
650
|
}
|
|
663
651
|
|
|
664
|
-
type
|
|
665
|
-
|
|
666
|
-
| Literal(normalizationLiteralArgument)
|
|
667
|
-
| ObjectValue(normalizationObjectValueArgument)
|
|
668
|
-
| Variable(normalizationVariableArgument)
|
|
669
|
-
|
|
670
|
-
let unwrapNormalizationArgument: normalizationArgumentWrapped => normalizationArgument
|
|
671
|
-
|
|
672
|
-
type normalizationScalarField = {
|
|
673
|
-
alias: Nullable.t<string>,
|
|
652
|
+
type normalizationLinkedField = {
|
|
653
|
+
alias: nullable<string>,
|
|
674
654
|
name: string,
|
|
675
|
-
|
|
676
|
-
|
|
655
|
+
storageKey: nullable<string>,
|
|
656
|
+
args: nullable<array<normalizationArgument>>,
|
|
657
|
+
concreteType: nullable<string>,
|
|
658
|
+
plural: bool,
|
|
659
|
+
selections: array<JSON.t>,
|
|
677
660
|
}
|
|
678
661
|
|
|
679
|
-
/**
|
|
662
|
+
/**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/).*/
|
|
663
|
+
@tag("kind")
|
|
664
|
+
type rec t =
|
|
665
|
+
/** a `MissingFieldHandler.t` for scalar fields. Give this a handler function that returns `null` (to indicate that data exists but is null), `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).*/
|
|
666
|
+
| @as("scalar")
|
|
667
|
+
Scalar({
|
|
668
|
+
handle: (
|
|
669
|
+
normalizationScalarField,
|
|
670
|
+
nullable<'record>,
|
|
671
|
+
'args,
|
|
672
|
+
ReadOnlyRecordSourceProxy.t,
|
|
673
|
+
) => nullable<'scalarValue>,
|
|
674
|
+
}): t
|
|
675
|
+
/** a `MissingFieldHandler.t` for linked fields (other objects/records). Give this a handler function that returns `null` (to indicate that the link exists but the linked record is null), `undefined` (to indicate data is still missing), or a `dataId` of the record that is linked at this field.*/
|
|
676
|
+
| @as("linked")
|
|
677
|
+
Linked({
|
|
678
|
+
handle: (
|
|
679
|
+
normalizationLinkedField,
|
|
680
|
+
nullable<'record>,
|
|
681
|
+
'args,
|
|
682
|
+
ReadOnlyRecordSourceProxy.t,
|
|
683
|
+
) => nullable<dataId>,
|
|
684
|
+
}): t
|
|
685
|
+
/** a `MissingFieldHandler.t` for lists of linked fields (other objects/records). Give this a handler function that returns `null` (to indicate that the link exists but the linked array of records is null), `undefined` (to indicate data is still missing), or an array of `nullable<dataId>` where the `dataId`'s are the linked records/objects.*/
|
|
686
|
+
| @as("pluralLinked")
|
|
687
|
+
PluralLinked({
|
|
688
|
+
handle: (
|
|
689
|
+
normalizationLinkedField,
|
|
690
|
+
nullable<'record>,
|
|
691
|
+
'args,
|
|
692
|
+
ReadOnlyRecordSourceProxy.t,
|
|
693
|
+
) => nullable<array<nullable<dataId>>>,
|
|
694
|
+
}): t
|
|
695
|
+
|
|
696
|
+
/**Make a `MissingFieldHandler.t` for scalar fields. Give this a handler function that returns `null` (to indicate that data exists but is null), `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).*/
|
|
680
697
|
let makeScalarMissingFieldHandler: (
|
|
681
698
|
(
|
|
682
699
|
normalizationScalarField,
|
|
683
700
|
Nullable.t<'record>,
|
|
684
701
|
'args,
|
|
685
702
|
ReadOnlyRecordSourceProxy.t,
|
|
686
|
-
) => 'scalarValue
|
|
703
|
+
) => Nullable.t<'scalarValue>
|
|
687
704
|
) => t
|
|
688
705
|
|
|
689
|
-
|
|
690
|
-
alias: Nullable.t<string>,
|
|
691
|
-
name: string,
|
|
692
|
-
storageKey: Nullable.t<string>,
|
|
693
|
-
args: Nullable.t<array<normalizationArgument>>,
|
|
694
|
-
concreteType: Nullable.t<string>,
|
|
695
|
-
plural: bool,
|
|
696
|
-
selections: array<JSON.t>,
|
|
697
|
-
}
|
|
698
|
-
|
|
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.*/
|
|
706
|
+
/**Make a `MissingFieldHandler.t` for linked fields (other objects/records). Give this a handler function that returns `null` (to indicate that the link exists but the linked record is null), `undefined` (to indicate data is still missing), or a `dataId` of the record that is linked at this field.*/
|
|
700
707
|
let makeLinkedMissingFieldHandler: (
|
|
701
708
|
(
|
|
702
709
|
normalizationLinkedField,
|
|
@@ -706,7 +713,7 @@ module MissingFieldHandler: {
|
|
|
706
713
|
) => Nullable.t<dataId>
|
|
707
714
|
) => t
|
|
708
715
|
|
|
709
|
-
/**Make a `MissingFieldHandler.t` for lists of linked fields (other objects/records). Give this a handler function that returns `
|
|
716
|
+
/**Make a `MissingFieldHandler.t` for lists of linked fields (other objects/records). Give this a handler function that returns `null` (to indicate that the link exists but the linked array of records is null), `undefined` (to indicate data is still missing), or an array of `nullable<dataId>` where the `dataId`'s are the linked records/objects.*/
|
|
710
717
|
let makePluralLinkedMissingFieldHandler: (
|
|
711
718
|
(
|
|
712
719
|
normalizationLinkedField,
|
|
@@ -33,15 +33,15 @@ function internal_removeUndefinedAndConvertNullsRaw(record) {
|
|
|
33
33
|
let value = param[1];
|
|
34
34
|
let key = param[0];
|
|
35
35
|
let match = Primitive_object.equal(value, Primitive_option.some(undefined));
|
|
36
|
-
if (
|
|
36
|
+
if (match) {
|
|
37
37
|
return [
|
|
38
38
|
key,
|
|
39
|
-
|
|
39
|
+
null
|
|
40
40
|
];
|
|
41
|
-
} else if (
|
|
41
|
+
} else if (value !== undefined) {
|
|
42
42
|
return [
|
|
43
43
|
key,
|
|
44
|
-
|
|
44
|
+
Primitive_option.valFromOption(value)
|
|
45
45
|
];
|
|
46
46
|
} else {
|
|
47
47
|
return;
|
|
@@ -20,8 +20,8 @@ let internal_cleanObjectFromUndefinedRaw = record =>
|
|
|
20
20
|
let internal_removeUndefinedAndConvertNullsRaw = record =>
|
|
21
21
|
internal_keepMapFieldsRaw(record, ((key, value)) => {
|
|
22
22
|
switch (value, value == Some(None)) {
|
|
23
|
-
| (Some(value), _) => Some((key, Nullable.make(value)))
|
|
24
23
|
| (_, true) => Some((key, Nullable.null))
|
|
24
|
+
| (Some(value), _) => Some((key, Nullable.make(value)))
|
|
25
25
|
| (None, _) => None
|
|
26
26
|
}
|
|
27
27
|
})
|