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.
- package/index.js +1 -1
- package/index.js.flow +2 -0
- package/lib/index.js +4 -1
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +20 -15
- package/lib/network/RelayNetwork.js +7 -3
- package/lib/query/fetchQuery.js +3 -0
- package/lib/store/RelayConcreteVariables.js +13 -3
- package/lib/store/RelayModernOperationDescriptor.js +1 -1
- package/lib/util/{getAllRootVariables.js → withProvidedVariables.js} +6 -6
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +45 -47
- package/network/RelayNetwork.js.flow +7 -3
- package/package.json +1 -1
- package/query/fetchQuery.js.flow +9 -7
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayConcreteVariables.js.flow +13 -2
- package/store/RelayModernOperationDescriptor.js.flow +5 -1
- package/util/{getAllRootVariables.js.flow → withProvidedVariables.js.flow} +6 -6
|
@@ -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.
|
|
80
|
-
*
|
|
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(
|
|
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
|
|
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
|
|
26
|
-
Object.assign(
|
|
25
|
+
const operationVariables = {};
|
|
26
|
+
Object.assign(operationVariables, userSuppliedVariables);
|
|
27
27
|
Object.keys(providedVariables).forEach((varName: string) => {
|
|
28
|
-
|
|
28
|
+
operationVariables[varName] = providedVariables[varName].get();
|
|
29
29
|
});
|
|
30
|
-
return
|
|
30
|
+
return operationVariables;
|
|
31
31
|
} else {
|
|
32
32
|
return userSuppliedVariables;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
module.exports =
|
|
36
|
+
module.exports = withProvidedVariables;
|