1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | 'use strict';
|
12 |
|
13 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
14 |
|
15 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
16 |
|
17 | var _require = require('relay-runtime'),
|
18 | getSelector = _require.getSelector;
|
19 |
|
20 | function getRootVariablesForFragments(fragments, props) {
|
21 | var rootVariables = {};
|
22 |
|
23 |
|
24 |
|
25 | Object.keys(fragments).forEach(function (key) {
|
26 | var _selector$selectors$, _selector$selectors$2, _selector$owner$varia;
|
27 |
|
28 | var fragmentNode = fragments[key];
|
29 | var fragmentRef = props[key];
|
30 | var selector = getSelector(fragmentNode, fragmentRef);
|
31 | var fragmentOwnerVariables = selector != null && selector.kind === 'PluralReaderSelector' ? (_selector$selectors$ = (_selector$selectors$2 = selector.selectors[0]) === null || _selector$selectors$2 === void 0 ? void 0 : _selector$selectors$2.owner.variables) !== null && _selector$selectors$ !== void 0 ? _selector$selectors$ : {} : (_selector$owner$varia = selector === null || selector === void 0 ? void 0 : selector.owner.variables) !== null && _selector$owner$varia !== void 0 ? _selector$owner$varia : {};
|
32 | rootVariables = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, rootVariables), fragmentOwnerVariables);
|
33 | });
|
34 | return rootVariables;
|
35 | }
|
36 |
|
37 | module.exports = getRootVariablesForFragments; |
\ | No newline at end of file |