relay-runtime 0.0.0-main-402aa970 → 0.0.0-main-2705e3dc

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.
@@ -40,6 +40,7 @@ const {
40
40
  ACTOR_IDENTIFIER_FIELD_NAME,
41
41
  getActorIdentifierFromPayload,
42
42
  } = require('../multi-actor-environment/ActorUtils');
43
+ const RelayFeatureFlags = require('../util/RelayFeatureFlags');
43
44
  const {generateClientID, isClientID} = require('./ClientID');
44
45
  const {getLocalVariables} = require('./RelayConcreteVariables');
45
46
  const {
@@ -471,7 +472,12 @@ class RelayResponseNormalizer {
471
472
  const responseKey = selection.alias || selection.name;
472
473
  const storageKey = getStorageKey(selection, this._variables);
473
474
  const fieldValue = data[responseKey];
474
- if (fieldValue == null) {
475
+ if (
476
+ fieldValue == null ||
477
+ (RelayFeatureFlags.ENABLE_NONCOMPLIANT_ERROR_HANDLING_ON_LISTS &&
478
+ Array.isArray(fieldValue) &&
479
+ fieldValue.length === 0)
480
+ ) {
475
481
  if (fieldValue === undefined) {
476
482
  // Fields may be missing in the response in two main cases:
477
483
  // - Inside a client extension: the server will not generally return
@@ -28,6 +28,14 @@ export type FeatureFlags = {
28
28
  LOG_MISSING_RECORDS_IN_PROD: boolean,
29
29
  ENABLE_RELAY_OPERATION_TRACKER_SUSPENSE: boolean,
30
30
 
31
+ // Some GraphQL servers are noncompliant with the GraphQL specification and
32
+ // return an empty list instead of null when there is a field error on a list.
33
+ //
34
+ // If this describes your server, enable this flag so that Relay will treat
35
+ // empty lists as null when deciding whether or not to check for field errors
36
+ // in the response.
37
+ ENABLE_NONCOMPLIANT_ERROR_HANDLING_ON_LISTS: boolean,
38
+
31
39
  // Configure RelayStoreSubscriptions to mark a subscription as affected by an
32
40
  // update if there are any overlapping IDs other than ROOT_ID or VIWER_ID,
33
41
  // even if none of the read fields were affected. The strict behavior (current
@@ -67,6 +75,7 @@ const RelayFeatureFlags: FeatureFlags = {
67
75
  MAX_DATA_ID_LENGTH: null,
68
76
  STRING_INTERN_LEVEL: 0,
69
77
  LOG_MISSING_RECORDS_IN_PROD: false,
78
+ ENABLE_NONCOMPLIANT_ERROR_HANDLING_ON_LISTS: false,
70
79
  ENABLE_LOOSE_SUBSCRIPTION_ATTRIBUTION: false,
71
80
  ENABLE_OPERATION_TRACKER_OPTIMISTIC_UPDATES: false,
72
81
  ENABLE_RELAY_OPERATION_TRACKER_SUSPENSE: false,