relay-runtime 0.0.0-main-21ca159d → 0.0.0-main-54586ecc
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/experimental.js +1 -1
- package/index.js +1 -1
- package/lib/store/RelayReader.js +28 -8
- package/package.json +1 -1
- package/relay-runtime-experimental.js +1 -1
- package/relay-runtime-experimental.min.js +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayReader.js.flow +33 -4
- package/util/ReaderNode.js.flow +1 -0
|
@@ -512,8 +512,19 @@ class RelayReader {
|
|
|
512
512
|
record: Record,
|
|
513
513
|
data: SelectorData,
|
|
514
514
|
): mixed {
|
|
515
|
-
const {fragment} = field;
|
|
516
515
|
const parentRecordID = RelayModernRecord.getDataID(record);
|
|
516
|
+
const result = this._readResolverFieldImpl(field, parentRecordID);
|
|
517
|
+
|
|
518
|
+
const applicationName = field.alias ?? field.name;
|
|
519
|
+
data[applicationName] = result;
|
|
520
|
+
return result;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
_readResolverFieldImpl(
|
|
524
|
+
field: ReaderRelayResolver | ReaderRelayLiveResolver,
|
|
525
|
+
parentRecordID: DataID,
|
|
526
|
+
): mixed {
|
|
527
|
+
const {fragment} = field;
|
|
517
528
|
|
|
518
529
|
// Found when reading the resolver fragment, which can happen either when
|
|
519
530
|
// evaluating the resolver and it calls readFragment, or when checking if the
|
|
@@ -613,8 +624,6 @@ class RelayReader {
|
|
|
613
624
|
updatedDataIDs,
|
|
614
625
|
);
|
|
615
626
|
|
|
616
|
-
const applicationName = field.alias ?? field.name;
|
|
617
|
-
data[applicationName] = result;
|
|
618
627
|
return result;
|
|
619
628
|
}
|
|
620
629
|
|
|
@@ -731,10 +740,18 @@ class RelayReader {
|
|
|
731
740
|
validClientEdgeResolverResponse.ids,
|
|
732
741
|
this._resolverCache,
|
|
733
742
|
);
|
|
743
|
+
let validStoreIDs: $ReadOnlyArray<?DataID> = storeIDs;
|
|
744
|
+
if (field.modelResolver != null) {
|
|
745
|
+
const modelResolver = field.modelResolver;
|
|
746
|
+
validStoreIDs = storeIDs.map(storeID => {
|
|
747
|
+
const model = this._readResolverFieldImpl(modelResolver, storeID);
|
|
748
|
+
return model != null ? storeID : null;
|
|
749
|
+
});
|
|
750
|
+
}
|
|
734
751
|
this._clientEdgeTraversalPath.push(null);
|
|
735
752
|
const edgeValues = this._readLinkedIds(
|
|
736
753
|
field.linkedField,
|
|
737
|
-
|
|
754
|
+
validStoreIDs,
|
|
738
755
|
record,
|
|
739
756
|
data,
|
|
740
757
|
);
|
|
@@ -749,6 +766,18 @@ class RelayReader {
|
|
|
749
766
|
validClientEdgeResolverResponse.id,
|
|
750
767
|
this._resolverCache,
|
|
751
768
|
);
|
|
769
|
+
if (field.modelResolver != null) {
|
|
770
|
+
const model = this._readResolverFieldImpl(
|
|
771
|
+
field.modelResolver,
|
|
772
|
+
storeID,
|
|
773
|
+
);
|
|
774
|
+
if (model == null) {
|
|
775
|
+
// If the model resolver returns undefined, we should still return null
|
|
776
|
+
// to match GQL behavior.
|
|
777
|
+
data[applicationName] = null;
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
752
781
|
this._clientEdgeTraversalPath.push(traversalPathSegment);
|
|
753
782
|
|
|
754
783
|
const prevData = data[applicationName];
|
package/util/ReaderNode.js.flow
CHANGED
|
@@ -274,6 +274,7 @@ export type ReaderRelayLiveResolver = {
|
|
|
274
274
|
export type ReaderClientEdgeToClientObject = {
|
|
275
275
|
+kind: 'ClientEdgeToClientObject',
|
|
276
276
|
+concreteType: string | null,
|
|
277
|
+
+modelResolver?: ReaderRelayResolver | ReaderRelayLiveResolver,
|
|
277
278
|
+linkedField: ReaderLinkedField,
|
|
278
279
|
+backingField:
|
|
279
280
|
| ReaderRelayResolver
|