react-relay 0.0.0-main-79c9ca49 → 0.0.0-main-aa6f91ae

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-79c9ca49
2
+ * Relay v0.0.0-main-aa6f91ae
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ * @oncall relay
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ const React = require('react');
15
+ const {
16
+ __internal: {createRelayLoggingContext},
17
+ } = require('relay-runtime');
18
+
19
+ module.exports = (createRelayLoggingContext(React): React.Context<
20
+ mixed | null,
21
+ >);
package/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-79c9ca49
2
+ * Relay v0.0.0-main-aa6f91ae
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-79c9ca49
2
+ * Relay v0.0.0-main-aa6f91ae
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/legacy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-79c9ca49
2
+ * Relay v0.0.0-main-aa6f91ae
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var _require = require('relay-runtime'),
5
+ createRelayLoggingContext = _require.__internal.createRelayLoggingContext;
6
+ module.exports = createRelayLoggingContext(React);
@@ -7,6 +7,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
7
7
  var _require = require('./QueryResource'),
8
8
  getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
9
9
  var useRelayEnvironment = require('./useRelayEnvironment');
10
+ var useRelayLoggingContext = require('./useRelayLoggingContext');
10
11
  var invariant = require('invariant');
11
12
  var _require2 = require('react'),
12
13
  useDebugValue = _require2.useDebugValue,
@@ -114,16 +115,16 @@ function getSuspendingLiveResolver(state) {
114
115
  return missingFields;
115
116
  }
116
117
  }
117
- function handlePotentialSnapshotErrorsForState(environment, state) {
118
+ function handlePotentialSnapshotErrorsForState(environment, state, loggingContext) {
118
119
  if (state.kind === 'singular') {
119
- handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors);
120
+ handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors, loggingContext);
120
121
  } else if (state.kind === 'plural') {
121
122
  var _iterator5 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
122
123
  _step5;
123
124
  try {
124
125
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
125
126
  var snapshot = _step5.value;
126
- handlePotentialSnapshotErrors(environment, snapshot.fieldErrors);
127
+ handlePotentialSnapshotErrors(environment, snapshot.fieldErrors, loggingContext);
127
128
  }
128
129
  } catch (err) {
129
130
  _iterator5.e(err);
@@ -309,6 +310,10 @@ function useFragmentInternal(fragmentNode, fragmentRef, hookDisplayName, queryOp
309
310
  }
310
311
  !(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + 'In this case, pass `null` if the conditions for evaluating the ' + 'fragment are not met (e.g. if the `@include(if)` value is false.)', fragmentNode.name, fragmentNode.name, hookDisplayName, fragmentNode.name, hookDisplayName) : invariant(false) : void 0;
311
312
  var environment = useRelayEnvironment();
313
+ var loggerContext;
314
+ if (RelayFeatureFlags.ENABLE_UI_CONTEXT_ON_RELAY_LOGGER) {
315
+ loggerContext = useRelayLoggingContext();
316
+ }
312
317
  var _useState = useState(function () {
313
318
  return getFragmentState(environment, fragmentSelector);
314
319
  }),
@@ -412,7 +417,7 @@ function useFragmentInternal(fragmentNode, fragmentRef, hookDisplayName, queryOp
412
417
  }
413
418
  }
414
419
  }
415
- handlePotentialSnapshotErrorsForState(environment, state);
420
+ handlePotentialSnapshotErrorsForState(environment, state, loggerContext);
416
421
  var hasPendingStateChanges = useRef(false);
417
422
  useEffect(function () {
418
423
  var currentState = subscribedState;
@@ -7,6 +7,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
7
7
  var _require = require('./QueryResource'),
8
8
  getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
9
9
  var useRelayEnvironment = require('./useRelayEnvironment');
10
+ var useRelayLoggingContext = require('./useRelayLoggingContext');
10
11
  var invariant = require('invariant');
11
12
  var _require2 = require('react'),
12
13
  useDebugValue = _require2.useDebugValue,
@@ -114,16 +115,16 @@ function getSuspendingLiveResolver(state) {
114
115
  return missingFields;
115
116
  }
116
117
  }
117
- function handlePotentialSnapshotErrorsForState(environment, state) {
118
+ function handlePotentialSnapshotErrorsForState(environment, state, loggingContext) {
118
119
  if (state.kind === 'singular') {
119
- handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors);
120
+ handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors, loggingContext);
120
121
  } else if (state.kind === 'plural') {
121
122
  var _iterator5 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
122
123
  _step5;
123
124
  try {
124
125
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
125
126
  var snapshot = _step5.value;
126
- handlePotentialSnapshotErrors(environment, snapshot.fieldErrors);
127
+ handlePotentialSnapshotErrors(environment, snapshot.fieldErrors, loggingContext);
127
128
  }
128
129
  } catch (err) {
129
130
  _iterator5.e(err);
@@ -324,6 +325,10 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
324
325
  }
325
326
  !(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + 'In this case, pass `null` if the conditions for evaluating the ' + 'fragment are not met (e.g. if the `@include(if)` value is false.)', fragmentNode.name, fragmentNode.name, hookDisplayName, fragmentNode.name, hookDisplayName) : invariant(false) : void 0;
326
327
  var environment = useRelayEnvironment();
328
+ var loggerContext;
329
+ if (RelayFeatureFlags.ENABLE_UI_CONTEXT_ON_RELAY_LOGGER) {
330
+ loggerContext = useRelayLoggingContext();
331
+ }
327
332
  var _useState = useState(function () {
328
333
  return getFragmentState(environment, fragmentSelector);
329
334
  }),
@@ -414,7 +419,7 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
414
419
  }
415
420
  }
416
421
  }
417
- handlePotentialSnapshotErrorsForState(environment, state);
422
+ handlePotentialSnapshotErrorsForState(environment, state, loggerContext);
418
423
  var storeSubscriptionRef = useRef(null);
419
424
  useEffect(function () {
420
425
  var storeSubscription = storeSubscriptionRef.current;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var ReactRelayLoggingContext = require('./../ReactRelayLoggingContext');
4
+ var _require = require('react'),
5
+ useContext = _require.useContext;
6
+ function useRelayLoggingContext() {
7
+ return useContext(ReactRelayLoggingContext);
8
+ }
9
+ module.exports = useRelayLoggingContext;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-relay",
3
3
  "description": "A framework for building GraphQL-driven React applications.",
4
- "version": "0.0.0-main-79c9ca49",
4
+ "version": "0.0.0-main-aa6f91ae",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay",
@@ -20,7 +20,7 @@
20
20
  "fbjs": "^3.0.2",
21
21
  "invariant": "^2.2.4",
22
22
  "nullthrows": "^1.1.1",
23
- "relay-runtime": "0.0.0-main-79c9ca49"
23
+ "relay-runtime": "0.0.0-main-aa6f91ae"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.9.0 || ^17 || ^18"
@@ -26,6 +26,7 @@ import type {MissingClientEdgeRequestInfo} from 'relay-runtime/store/RelayStoreT
26
26
 
27
27
  const {getQueryResourceForEnvironment} = require('./QueryResource');
28
28
  const useRelayEnvironment = require('./useRelayEnvironment');
29
+ const useRelayLoggingContext = require('./useRelayLoggingContext');
29
30
  const invariant = require('invariant');
30
31
  const {useDebugValue, useEffect, useMemo, useRef, useState} = require('react');
31
32
  const {
@@ -109,12 +110,21 @@ function getSuspendingLiveResolver(
109
110
  function handlePotentialSnapshotErrorsForState(
110
111
  environment: IEnvironment,
111
112
  state: FragmentState,
113
+ loggingContext: mixed | void,
112
114
  ): void {
113
115
  if (state.kind === 'singular') {
114
- handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors);
116
+ handlePotentialSnapshotErrors(
117
+ environment,
118
+ state.snapshot.fieldErrors,
119
+ loggingContext,
120
+ );
115
121
  } else if (state.kind === 'plural') {
116
122
  for (const snapshot of state.snapshots) {
117
- handlePotentialSnapshotErrors(environment, snapshot.fieldErrors);
123
+ handlePotentialSnapshotErrors(
124
+ environment,
125
+ snapshot.fieldErrors,
126
+ loggingContext,
127
+ );
118
128
  }
119
129
  }
120
130
  }
@@ -400,6 +410,11 @@ hook useFragmentInternal(
400
410
  );
401
411
 
402
412
  const environment = useRelayEnvironment();
413
+ let loggerContext;
414
+ if (RelayFeatureFlags.ENABLE_UI_CONTEXT_ON_RELAY_LOGGER) {
415
+ // $FlowFixMe[react-rule-hook] - the condition is static
416
+ loggerContext = useRelayLoggingContext();
417
+ }
403
418
  const [_state, setState] = useState<FragmentState>(() =>
404
419
  getFragmentState(environment, fragmentSelector),
405
420
  );
@@ -538,7 +553,7 @@ hook useFragmentInternal(
538
553
 
539
554
  // Report required fields only if we're not suspending, since that means
540
555
  // they're missing even though we are out of options for possibly fetching them:
541
- handlePotentialSnapshotErrorsForState(environment, state);
556
+ handlePotentialSnapshotErrorsForState(environment, state, loggerContext);
542
557
 
543
558
  const hasPendingStateChanges = useRef<boolean>(false);
544
559
 
@@ -26,6 +26,7 @@ import type {MissingClientEdgeRequestInfo} from 'relay-runtime/store/RelayStoreT
26
26
 
27
27
  const {getQueryResourceForEnvironment} = require('./QueryResource');
28
28
  const useRelayEnvironment = require('./useRelayEnvironment');
29
+ const useRelayLoggingContext = require('./useRelayLoggingContext');
29
30
  const invariant = require('invariant');
30
31
  const {useDebugValue, useEffect, useMemo, useRef, useState} = require('react');
31
32
  const {
@@ -121,12 +122,21 @@ function getSuspendingLiveResolver(
121
122
  function handlePotentialSnapshotErrorsForState(
122
123
  environment: IEnvironment,
123
124
  state: FragmentState,
125
+ loggingContext: mixed | void,
124
126
  ): void {
125
127
  if (state.kind === 'singular') {
126
- handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors);
128
+ handlePotentialSnapshotErrors(
129
+ environment,
130
+ state.snapshot.fieldErrors,
131
+ loggingContext,
132
+ );
127
133
  } else if (state.kind === 'plural') {
128
134
  for (const snapshot of state.snapshots) {
129
- handlePotentialSnapshotErrors(environment, snapshot.fieldErrors);
135
+ handlePotentialSnapshotErrors(
136
+ environment,
137
+ snapshot.fieldErrors,
138
+ loggingContext,
139
+ );
130
140
  }
131
141
  }
132
142
  }
@@ -428,6 +438,11 @@ hook useFragmentInternal_EXPERIMENTAL(
428
438
  );
429
439
 
430
440
  const environment = useRelayEnvironment();
441
+ let loggerContext;
442
+ if (RelayFeatureFlags.ENABLE_UI_CONTEXT_ON_RELAY_LOGGER) {
443
+ // $FlowFixMe[react-rule-hook] - the condition is static
444
+ loggerContext = useRelayLoggingContext();
445
+ }
431
446
  const [_state, setState] = useState<FragmentState>(() =>
432
447
  getFragmentState(environment, fragmentSelector),
433
448
  );
@@ -553,7 +568,7 @@ hook useFragmentInternal_EXPERIMENTAL(
553
568
 
554
569
  // Report required fields only if we're not suspending, since that means
555
570
  // they're missing even though we are out of options for possibly fetching them:
556
- handlePotentialSnapshotErrorsForState(environment, state);
571
+ handlePotentialSnapshotErrorsForState(environment, state, loggerContext);
557
572
 
558
573
  // We emulate CRUD effects using a ref and two effects:
559
574
  // - The ref tracks the current state (including updates from the subscription)
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ * @oncall relay
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ const ReactRelayLoggingContext = require('./../ReactRelayLoggingContext');
15
+ const {useContext} = require('react');
16
+
17
+ hook useRelayLoggingContext(): mixed | void {
18
+ return useContext(ReactRelayLoggingContext);
19
+ }
20
+
21
+ module.exports = useRelayLoggingContext;