relay-runtime 0.0.0-main-9262f2ac → 0.0.0-main-668c9f2e

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-9262f2ac
2
+ * Relay v0.0.0-main-668c9f2e
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
5
5
  *
@@ -73,12 +73,8 @@ const {
73
73
  STREAM,
74
74
  TYPE_DISCRIMINATOR,
75
75
  } = RelayConcreteNode;
76
- const {
77
- ROOT_ID,
78
- getModuleOperationKey,
79
- getStorageKey,
80
- getArgumentValues,
81
- } = RelayStoreUtils;
76
+ const {ROOT_ID, getModuleOperationKey, getStorageKey, getArgumentValues} =
77
+ RelayStoreUtils;
82
78
 
83
79
  /**
84
80
  * Synchronously check whether the records required to fulfill the given
@@ -592,10 +588,8 @@ class DataChecker {
592
588
  const prevMutator = this._mutator;
593
589
  const prevRecordSourceProxy = this._recordSourceProxy;
594
590
 
595
- const [
596
- mutator,
597
- recordSourceProxy,
598
- ] = this._getMutatorAndRecordProxyForActor(actorIdentifier);
591
+ const [mutator, recordSourceProxy] =
592
+ this._getMutatorAndRecordProxyForActor(actorIdentifier);
599
593
 
600
594
  this._source = this._getSourceForActor(actorIdentifier);
601
595
  this._mutator = mutator;
@@ -448,7 +448,8 @@ class Executor<TMutation: MutationParameters> {
448
448
  error.stack;
449
449
  throw error;
450
450
  } else {
451
- const responseWithData: GraphQLResponseWithData = (response: $FlowFixMe);
451
+ const responseWithData: GraphQLResponseWithData =
452
+ (response: $FlowFixMe);
452
453
  results.push(responseWithData);
453
454
  }
454
455
  });
@@ -523,10 +524,8 @@ class Executor<TMutation: MutationParameters> {
523
524
  return;
524
525
  }
525
526
 
526
- const [
527
- nonIncrementalResponses,
528
- incrementalResponses,
529
- ] = partitionGraphQLResponses(responsesWithData);
527
+ const [nonIncrementalResponses, incrementalResponses] =
528
+ partitionGraphQLResponses(responsesWithData);
530
529
  const hasNonIncrementalResponses = nonIncrementalResponses.length > 0;
531
530
 
532
531
  // In theory this doesn't preserve the ordering of the batch.
@@ -563,9 +562,8 @@ class Executor<TMutation: MutationParameters> {
563
562
  }
564
563
 
565
564
  if (incrementalResponses.length > 0) {
566
- const payloadFollowups = this._processIncrementalResponses(
567
- incrementalResponses,
568
- );
565
+ const payloadFollowups =
566
+ this._processIncrementalResponses(incrementalResponses);
569
567
 
570
568
  this._processPayloadFollowups(payloadFollowups);
571
569
  }
@@ -578,7 +576,8 @@ class Executor<TMutation: MutationParameters> {
578
576
  __relay_subscription_root_id: this._operation.fragment.dataID,
579
577
  };
580
578
  } else {
581
- responsesWithData[0].extensions.__relay_subscription_root_id = this._operation.fragment.dataID;
579
+ responsesWithData[0].extensions.__relay_subscription_root_id =
580
+ this._operation.fragment.dataID;
582
581
  }
583
582
  }
584
583
 
@@ -677,10 +676,8 @@ class Executor<TMutation: MutationParameters> {
677
676
  if (operation == null) {
678
677
  this._processAsyncOptimisticModuleImport(followupPayload);
679
678
  } else {
680
- const moduleImportOptimisticUpdates = this._processOptimisticModuleImport(
681
- operation,
682
- followupPayload,
683
- );
679
+ const moduleImportOptimisticUpdates =
680
+ this._processOptimisticModuleImport(operation, followupPayload);
684
681
  optimisticUpdates.push(...moduleImportOptimisticUpdates);
685
682
  }
686
683
  break;
@@ -775,10 +772,8 @@ class Executor<TMutation: MutationParameters> {
775
772
  if (operation == null || this._state !== 'started') {
776
773
  return;
777
774
  }
778
- const moduleImportOptimisticUpdates = this._processOptimisticModuleImport(
779
- operation,
780
- moduleImportPayload,
781
- );
775
+ const moduleImportOptimisticUpdates =
776
+ this._processOptimisticModuleImport(operation, moduleImportPayload);
782
777
  moduleImportOptimisticUpdates.forEach(update =>
783
778
  this._getPublishQueueAndSaveActor().applyUpdate(update),
784
779
  );
@@ -1180,9 +1175,8 @@ class Executor<TMutation: MutationParameters> {
1180
1175
  // If there were any queued responses, process them now that placeholders
1181
1176
  // are in place
1182
1177
  if (pendingResponses != null) {
1183
- const payloadFollowups = this._processIncrementalResponses(
1184
- pendingResponses,
1185
- );
1178
+ const payloadFollowups =
1179
+ this._processIncrementalResponses(pendingResponses);
1186
1180
  this._processPayloadFollowups(payloadFollowups);
1187
1181
  }
1188
1182
  }
@@ -1232,10 +1226,7 @@ class Executor<TMutation: MutationParameters> {
1232
1226
  // but Relay records paths relative to the parent of the stream node:
1233
1227
  // therefore we strip the last two elements just to lookup the path
1234
1228
  // (the item index is used later to insert the element in the list)
1235
- const pathKey = path
1236
- .slice(0, -2)
1237
- .map(String)
1238
- .join('.');
1229
+ const pathKey = path.slice(0, -2).map(String).join('.');
1239
1230
  let resultForPath = resultForLabel.get(pathKey);
1240
1231
  if (resultForPath == null) {
1241
1232
  resultForPath = {kind: 'response', responses: [incrementalResponse]};
@@ -45,7 +45,7 @@ const warning = require('warning');
45
45
  type Props = {[key: string]: mixed, ...};
46
46
  type Resolvers = {
47
47
  [key: string]: ?(SelectorListResolver | SelectorResolver),
48
- ...,
48
+ ...
49
49
  };
50
50
 
51
51
  /**
@@ -49,9 +49,8 @@ class RelayOperationTracker {
49
49
  const newlyAffectedOwnersIdentifier = new Set();
50
50
  for (const owner of affectedOwners) {
51
51
  const ownerIdentifier = owner.identifier;
52
- const pendingOperationsAffectingOwner = this._ownersToPendingOperations.get(
53
- ownerIdentifier,
54
- );
52
+ const pendingOperationsAffectingOwner =
53
+ this._ownersToPendingOperations.get(ownerIdentifier);
55
54
  if (pendingOperationsAffectingOwner != null) {
56
55
  // In this case the `ownerIdentifier` already affected by some operations
57
56
  // We just need to detect, is it the same operation that we already
@@ -113,9 +112,8 @@ class RelayOperationTracker {
113
112
  // and some other operations
114
113
  const updatedOwnersIdentifier = new Set();
115
114
  for (const ownerIdentifier of affectedOwnersIdentifier) {
116
- const pendingOperationsAffectingOwner = this._ownersToPendingOperations.get(
117
- ownerIdentifier,
118
- );
115
+ const pendingOperationsAffectingOwner =
116
+ this._ownersToPendingOperations.get(ownerIdentifier);
119
117
  if (!pendingOperationsAffectingOwner) {
120
118
  continue;
121
119
  }
@@ -151,16 +149,13 @@ class RelayOperationTracker {
151
149
  this._ownersToPendingPromise.delete(ownerIdentifier);
152
150
  }
153
151
 
154
- getPendingOperationsAffectingOwner(
155
- owner: RequestDescriptor,
156
- ): {|
152
+ getPendingOperationsAffectingOwner(owner: RequestDescriptor): {|
157
153
  promise: Promise<void>,
158
154
  pendingOperations: $ReadOnlyArray<RequestDescriptor>,
159
155
  |} | null {
160
156
  const ownerIdentifier = owner.identifier;
161
- const pendingOperationsForOwner = this._ownersToPendingOperations.get(
162
- ownerIdentifier,
163
- );
157
+ const pendingOperationsForOwner =
158
+ this._ownersToPendingOperations.get(ownerIdentifier);
164
159
  if (
165
160
  pendingOperationsForOwner == null ||
166
161
  pendingOperationsForOwner.size === 0
@@ -168,9 +163,8 @@ class RelayOperationTracker {
168
163
  return null;
169
164
  }
170
165
 
171
- const cachedPromiseEntry = this._ownersToPendingPromise.get(
172
- ownerIdentifier,
173
- );
166
+ const cachedPromiseEntry =
167
+ this._ownersToPendingPromise.get(ownerIdentifier);
174
168
  if (cachedPromiseEntry != null) {
175
169
  return {
176
170
  promise: cachedPromiseEntry.promise,
@@ -307,7 +307,8 @@ class RelayPublishQueue implements PublishQueue {
307
307
  const selectorData = lookupSelector(source, selector);
308
308
  updater(recordSourceSelectorProxy, selectorData);
309
309
  }
310
- const idsMarkedForInvalidation = recordSourceProxy.getIDsMarkedForInvalidation();
310
+ const idsMarkedForInvalidation =
311
+ recordSourceProxy.getIDsMarkedForInvalidation();
311
312
  this._store.publish(source, idsMarkedForInvalidation);
312
313
  return recordSourceProxy.isStoreMarkedForInvalidation();
313
314
  }
@@ -348,7 +349,8 @@ class RelayPublishQueue implements PublishQueue {
348
349
  );
349
350
  invalidatedStore =
350
351
  invalidatedStore || recordSourceProxy.isStoreMarkedForInvalidation();
351
- const idsMarkedForInvalidation = recordSourceProxy.getIDsMarkedForInvalidation();
352
+ const idsMarkedForInvalidation =
353
+ recordSourceProxy.getIDsMarkedForInvalidation();
352
354
 
353
355
  this._store.publish(sink, idsMarkedForInvalidation);
354
356
  }
@@ -322,8 +322,8 @@ class RelayReader {
322
322
 
323
323
  // store flags to reset after reading
324
324
  const parentIsMissingData = this._isMissingData;
325
- const parentIsWithinUnmatchedTypeRefinement = this
326
- ._isWithinUnmatchedTypeRefinement;
325
+ const parentIsWithinUnmatchedTypeRefinement =
326
+ this._isWithinUnmatchedTypeRefinement;
327
327
 
328
328
  const typeName = RelayModernRecord.getType(record);
329
329
  const typeID = generateTypeID(typeName);
@@ -336,7 +336,8 @@ class RelayReader {
336
336
  parentIsWithinUnmatchedTypeRefinement ||
337
337
  implementsInterface === false;
338
338
  this._traverseSelections(selection.selections, record, data);
339
- this._isWithinUnmatchedTypeRefinement = parentIsWithinUnmatchedTypeRefinement;
339
+ this._isWithinUnmatchedTypeRefinement =
340
+ parentIsWithinUnmatchedTypeRefinement;
340
341
 
341
342
  if (implementsInterface === false) {
342
343
  // Type known to not implement the interface, no data expected
@@ -533,10 +534,8 @@ class RelayReader {
533
534
  ): ?mixed {
534
535
  const applicationName = field.alias ?? field.name;
535
536
  const storageKey = getStorageKey(field, this._variables);
536
- const reactFlightClientResponseRecordID = RelayModernRecord.getLinkedRecordID(
537
- record,
538
- storageKey,
539
- );
537
+ const reactFlightClientResponseRecordID =
538
+ RelayModernRecord.getLinkedRecordID(record, storageKey);
540
539
  if (reactFlightClientResponseRecordID == null) {
541
540
  data[applicationName] = reactFlightClientResponseRecordID;
542
541
  if (reactFlightClientResponseRecordID === undefined) {
@@ -757,9 +756,8 @@ class RelayReader {
757
756
  ? getArgumentValues(fragmentSpread.args, this._variables)
758
757
  : {};
759
758
  data[FRAGMENT_OWNER_KEY] = this._owner;
760
- data[
761
- IS_WITHIN_UNMATCHED_TYPE_REFINEMENT
762
- ] = this._isWithinUnmatchedTypeRefinement;
759
+ data[IS_WITHIN_UNMATCHED_TYPE_REFINEMENT] =
760
+ this._isWithinUnmatchedTypeRefinement;
763
761
  }
764
762
 
765
763
  _createInlineDataOrResolverFragmentPointer(
@@ -505,7 +505,11 @@ class RelayResponseNormalizer {
505
505
  this._validateConflictingFieldsWithIdenticalId(
506
506
  record,
507
507
  storageKey,
508
- fieldValue,
508
+ // When using `treatMissingFieldsAsNull` the conflicting validation raises a false positive
509
+ // because the value is set using `null` but validated using `fieldValue` which at this point
510
+ // will be `undefined`.
511
+ // Setting this to `null` matches the value that we actually set to the `fieldValue`.
512
+ null,
509
513
  );
510
514
  }
511
515
  }
@@ -762,7 +766,8 @@ class RelayResponseNormalizer {
762
766
  reactFlightClientResponse,
763
767
  );
764
768
 
765
- const reachableExecutableDefinitions: Array<ReactFlightReachableExecutableDefinitions> = [];
769
+ const reachableExecutableDefinitions: Array<ReactFlightReachableExecutableDefinitions> =
770
+ [];
766
771
  for (const query of reactFlightPayload.queries) {
767
772
  if (query.response.data != null) {
768
773
  this._followupPayloads.push({
@@ -69,14 +69,8 @@ function requestSubscription<TSubscriptionPayload>(
69
69
  if (subscription.params.operationKind !== 'subscription') {
70
70
  throw new Error('requestSubscription: Must use Subscription operation');
71
71
  }
72
- const {
73
- configs,
74
- onCompleted,
75
- onError,
76
- onNext,
77
- variables,
78
- cacheConfig,
79
- } = config;
72
+ const {configs, onCompleted, onError, onNext, variables, cacheConfig} =
73
+ config;
80
74
  const operation = createOperationDescriptor(
81
75
  subscription,
82
76
  variables,
@@ -32,10 +32,8 @@ function getPaginationMetadata(
32
32
  paginationMetadata: ReaderPaginationMetadata,
33
33
  stream: boolean,
34
34
  |} {
35
- const {
36
- refetchableRequest: paginationRequest,
37
- refetchMetadata,
38
- } = getRefetchMetadata(fragmentNode, componentDisplayName);
35
+ const {refetchableRequest: paginationRequest, refetchMetadata} =
36
+ getRefetchMetadata(fragmentNode, componentDisplayName);
39
37
 
40
38
  const paginationMetadata = refetchMetadata.connection;
41
39
  invariant(
@@ -29,10 +29,8 @@ function getPaginationVariables(
29
29
  extraVariables: Variables,
30
30
  paginationMetadata: ReaderPaginationMetadata,
31
31
  ): {[string]: mixed, ...} {
32
- const {
33
- backward: backwardMetadata,
34
- forward: forwardMetadata,
35
- } = paginationMetadata;
32
+ const {backward: backwardMetadata, forward: forwardMetadata} =
33
+ paginationMetadata;
36
34
 
37
35
  if (direction === 'backward') {
38
36
  invariant(
@@ -51,11 +51,10 @@ function getRefetchMetadata(
51
51
  );
52
52
 
53
53
  // handle both commonjs and es modules
54
- const refetchableRequest:
55
- | ConcreteRequest
56
- | string = (refetchMetadata: $FlowFixMe).operation.default
57
- ? (refetchMetadata: $FlowFixMe).operation.default
58
- : refetchMetadata.operation;
54
+ const refetchableRequest: ConcreteRequest | string =
55
+ (refetchMetadata: $FlowFixMe).operation.default
56
+ ? (refetchMetadata: $FlowFixMe).operation.default
57
+ : refetchMetadata.operation;
59
58
  const fragmentRefPathInResponse = refetchMetadata.fragmentPathInResult;
60
59
  invariant(
61
60
  typeof refetchableRequest !== 'string',