37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* strict-local
|
|
* @format
|
|
*/
|
|
'use strict';
|
|
|
|
var _objectSpread2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
|
|
|
|
/**
|
|
* @private
|
|
*
|
|
* Creates a clone of the supplied `handleField` by finding the original linked
|
|
* field (on which the handle was declared) among the sibling `selections`, and
|
|
* copying its selections into the clone.
|
|
*/
|
|
function cloneRelayHandleSourceField(handleField, selections, variables) {
|
|
var sourceField = selections.find(function (source) {
|
|
return source.kind === require("./RelayConcreteNode").LINKED_FIELD && source.name === handleField.name && source.alias === handleField.alias && require("fbjs/lib/areEqual")(source.args, handleField.args);
|
|
});
|
|
!(sourceField && sourceField.kind === require("./RelayConcreteNode").LINKED_FIELD) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'cloneRelayHandleSourceField: Expected a corresponding source field for ' + 'handle `%s`.', handleField.handle) : require("fbjs/lib/invariant")(false) : void 0;
|
|
|
|
var handleKey = require("./RelayStoreUtils").getHandleStorageKey(handleField, variables);
|
|
|
|
var clonedField = (0, _objectSpread2["default"])({}, sourceField, {
|
|
args: null,
|
|
name: handleKey,
|
|
storageKey: handleKey
|
|
});
|
|
return clonedField;
|
|
}
|
|
|
|
module.exports = cloneRelayHandleSourceField; |