relay-runtime 13.0.0 → 13.0.1

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.
@@ -18,6 +18,7 @@ import type {
18
18
  NormalizationOperation,
19
19
  } from '../util/NormalizationNode';
20
20
  import type {ReaderFragment} from '../util/ReaderNode';
21
+ import type {RequestParameters} from '../util/RelayConcreteNode';
21
22
  import type {Variables} from '../util/RelayRuntimeTypes';
22
23
 
23
24
  const {getArgumentValues} = require('./RelayStoreUtils');
@@ -76,12 +77,15 @@ function getFragmentVariables(
76
77
 
77
78
  /**
78
79
  * Determines the variables that are in scope for a given operation given values
79
- * for some/all of its arguments. Extraneous input variables are filtered from
80
- * the output, and missing variables are set to default values (if given in the
80
+ * for some/all of its arguments.
81
+ * - extraneous input variables are filtered from the output
82
+ * - missing variables are set to default values (if given in the
81
83
  * operation's definition).
84
+ * - variables with provider modules are added
82
85
  */
83
86
  function getOperationVariables(
84
87
  operation: NormalizationOperation,
88
+ parameters: RequestParameters,
85
89
  variables: Variables,
86
90
  ): Variables {
87
91
  const operationVariables = {};
@@ -92,6 +96,13 @@ function getOperationVariables(
92
96
  }
93
97
  operationVariables[def.name] = value;
94
98
  });
99
+
100
+ const providedVariables = parameters.providedVariables;
101
+ if (providedVariables != null) {
102
+ Object.keys(providedVariables).forEach((varName: string) => {
103
+ operationVariables[varName] = providedVariables[varName].get();
104
+ });
105
+ }
95
106
  return operationVariables;
96
107
  }
97
108
 
@@ -44,7 +44,11 @@ function createOperationDescriptor<TQuery: OperationType>(
44
44
  dataID?: DataID = ROOT_ID,
45
45
  ): OperationDescriptor {
46
46
  const operation = request.operation;
47
- const operationVariables = getOperationVariables(operation, variables);
47
+ const operationVariables = getOperationVariables(
48
+ operation,
49
+ request.params,
50
+ variables,
51
+ );
48
52
  const requestDescriptor = createRequestDescriptor(
49
53
  request,
50
54
  operationVariables,
@@ -16,21 +16,21 @@
16
16
  import type {RequestParameters} from './RelayConcreteNode';
17
17
  import type {Variables} from './RelayRuntimeTypes';
18
18
 
19
- function getAllRootVariables(
19
+ function withProvidedVariables(
20
20
  userSuppliedVariables: Variables,
21
21
  parameters: RequestParameters,
22
22
  ): Variables {
23
23
  const providedVariables = parameters.providedVariables;
24
24
  if (providedVariables != null) {
25
- const allVariables = {};
26
- Object.assign(allVariables, userSuppliedVariables);
25
+ const operationVariables = {};
26
+ Object.assign(operationVariables, userSuppliedVariables);
27
27
  Object.keys(providedVariables).forEach((varName: string) => {
28
- allVariables[varName] = providedVariables[varName].get();
28
+ operationVariables[varName] = providedVariables[varName].get();
29
29
  });
30
- return allVariables;
30
+ return operationVariables;
31
31
  } else {
32
32
  return userSuppliedVariables;
33
33
  }
34
34
  }
35
35
 
36
- module.exports = getAllRootVariables;
36
+ module.exports = withProvidedVariables;