relay-runtime 0.0.0-main-f82885c1 → 0.0.0-main-857a579c

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-f82885c1
2
+ * Relay v0.0.0-main-857a579c
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -21,7 +21,7 @@ var _require = require('../query/GraphQLTag'),
21
21
  var _require2 = require('../store/RelayStoreUtils'),
22
22
  getArgumentValues = _require2.getArgumentValues;
23
23
 
24
- var nonUpdatableKeys = ['id', '__id', '__typename'];
24
+ var nonUpdatableKeys = ['id', '__id', '__typename', 'js'];
25
25
 
26
26
  function readUpdatableQuery_EXPERIMENTAL(query, variables, proxy) {
27
27
  // TODO assert that the concrete request is an updatable query
@@ -163,7 +163,7 @@ function createSetterForSingularLinkedField(selection, queryVariables, recordPro
163
163
 
164
164
  if (newValue == null) {
165
165
  // $FlowFixMe[unclear-type] No good way to type these variables
166
- recordProxy.setValue(null, selection.name, variables);
166
+ recordProxy.setValue(newValue, selection.name, variables);
167
167
  } else {
168
168
  var __id = newValue.__id;
169
169
 
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.normalizeResponse = normalizeResponse;
9
+ exports.normalizeResponseWithMetadata = normalizeResponseWithMetadata;
10
+ exports.GraphModeNormalizer = void 0;
9
11
 
10
12
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
11
13
 
@@ -30,7 +32,9 @@ var _require = require('../util/RelayConcreteNode'),
30
32
  FRAGMENT_SPREAD = _require.FRAGMENT_SPREAD,
31
33
  INLINE_FRAGMENT = _require.INLINE_FRAGMENT,
32
34
  LINKED_FIELD = _require.LINKED_FIELD,
33
- SCALAR_FIELD = _require.SCALAR_FIELD;
35
+ LINKED_HANDLE = _require.LINKED_HANDLE,
36
+ SCALAR_FIELD = _require.SCALAR_FIELD,
37
+ SCALAR_HANDLE = _require.SCALAR_HANDLE;
34
38
 
35
39
  var _require2 = require('./RelayConcreteVariables'),
36
40
  getLocalVariables = _require2.getLocalVariables;
@@ -96,6 +100,17 @@ function normalizeResponse(response, selector, options) {
96
100
  return normalizer.normalizeResponse(node, dataID, response);
97
101
  }
98
102
 
103
+ function normalizeResponseWithMetadata(response, selector, options) {
104
+ var node = selector.node,
105
+ variables = selector.variables,
106
+ dataID = selector.dataID;
107
+ var normalizer = new GraphModeNormalizer(variables, options);
108
+ var chunks = Array.from(normalizer.normalizeResponse(node, dataID, response));
109
+ return [chunks, {
110
+ duplicateFieldsAvoided: normalizer.duplicateFieldsAvoided
111
+ }];
112
+ }
113
+
99
114
  var GraphModeNormalizer = /*#__PURE__*/function () {
100
115
  function GraphModeNormalizer(variables, options) {
101
116
  this._actorIdentifier = options.actorIdentifier;
@@ -105,6 +120,7 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
105
120
  this._sentFields = new Map();
106
121
  this._nextStreamID = 0;
107
122
  this._variables = variables;
123
+ this.duplicateFieldsAvoided = 0;
108
124
  }
109
125
 
110
126
  var _proto = GraphModeNormalizer.prototype;
@@ -218,6 +234,7 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
218
234
 
219
235
 
220
236
  if (sentFields.has(storageKey)) {
237
+ this.duplicateFieldsAvoided++;
221
238
  break;
222
239
  }
223
240
 
@@ -237,6 +254,7 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
237
254
 
238
255
 
239
256
  if (sentFields.has(_storageKey)) {
257
+ this.duplicateFieldsAvoided++;
240
258
  break;
241
259
  }
242
260
 
@@ -310,6 +328,18 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
310
328
  // over client extensions.
311
329
  break;
312
330
 
331
+ case SCALAR_HANDLE:
332
+ case LINKED_HANDLE:
333
+ // Handles allow us to record information that will be needed to
334
+ // perform additional process when we insert data into the store. For
335
+ // example, connection edges need to be prepended/appended to the
336
+ // pre-existing values.
337
+ //
338
+ // GraphMode will eventually need some replacement for this, but it is
339
+ // not nessesary in order to measure things like response size, so we
340
+ // can ignore these for now.
341
+ break;
342
+
313
343
  default:
314
344
  throw new Error("Unexpected selection type: ".concat(selection.kind));
315
345
  }
@@ -388,4 +418,6 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
388
418
  };
389
419
 
390
420
  return GraphModeNormalizer;
391
- }();
421
+ }();
422
+
423
+ exports.GraphModeNormalizer = GraphModeNormalizer;
@@ -21,7 +21,7 @@ import type {OperationType} from '../util/RelayRuntimeTypes';
21
21
  const {getRequest} = require('../query/GraphQLTag');
22
22
  const {getArgumentValues} = require('../store/RelayStoreUtils');
23
23
 
24
- const nonUpdatableKeys = ['id', '__id', '__typename'];
24
+ const nonUpdatableKeys = ['id', '__id', '__typename', 'js'];
25
25
 
26
26
  function readUpdatableQuery_EXPERIMENTAL<TQuery: OperationType>(
27
27
  query: GraphQLTaggedNode,
@@ -214,7 +214,7 @@ function createSetterForSingularLinkedField<TQuery: OperationType>(
214
214
  const variables = getArgumentValues(selection.args ?? [], queryVariables);
215
215
  if (newValue == null) {
216
216
  // $FlowFixMe[unclear-type] No good way to type these variables
217
- recordProxy.setValue(null, selection.name, (variables: any));
217
+ recordProxy.setValue(newValue, selection.name, (variables: any));
218
218
  } else {
219
219
  const {__id} = newValue;
220
220
  if (__id == null) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "relay-runtime",
3
3
  "description": "A core runtime for building GraphQL-driven applications.",
4
- "version": "0.0.0-main-f82885c1",
4
+ "version": "0.0.0-main-857a579c",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay"