relay-runtime 0.0.0-main-378104f3 → 0.0.0-main-4176c0e5
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 -2
- package/lib/index.js +4 -4
- package/lib/network/RelayNetwork.js +5 -5
- package/lib/store/RelayConcreteVariables.js +4 -2
- package/lib/util/{getAllRootVariables.js → withProvidedVariables.js} +6 -6
- package/network/RelayNetwork.js.flow +5 -5
- package/package.json +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayConcreteVariables.js.flow +4 -2
- package/util/{getAllRootVariables.js.flow → withProvidedVariables.js.flow} +6 -6
package/index.js
CHANGED
package/index.js.flow
CHANGED
|
@@ -51,7 +51,6 @@ const ViewerPattern = require('./store/ViewerPattern');
|
|
|
51
51
|
const requestSubscription = require('./subscription/requestSubscription');
|
|
52
52
|
const createPayloadFor3DField = require('./util/createPayloadFor3DField');
|
|
53
53
|
const deepFreeze = require('./util/deepFreeze');
|
|
54
|
-
const getAllRootVariables = require('./util/getAllRootVariables');
|
|
55
54
|
const getFragmentIdentifier = require('./util/getFragmentIdentifier');
|
|
56
55
|
const getPaginationMetadata = require('./util/getPaginationMetadata');
|
|
57
56
|
const getPaginationVariables = require('./util/getPaginationVariables');
|
|
@@ -71,6 +70,7 @@ const RelayProfiler = require('./util/RelayProfiler');
|
|
|
71
70
|
const RelayReplaySubject = require('./util/RelayReplaySubject');
|
|
72
71
|
const reportMissingRequiredFields = require('./util/reportMissingRequiredFields');
|
|
73
72
|
const stableCopy = require('./util/stableCopy');
|
|
73
|
+
const withProvidedVariables = require('./util/withProvidedVariables');
|
|
74
74
|
|
|
75
75
|
export type {ConnectionMetadata} from './handlers/connection/ConnectionHandler';
|
|
76
76
|
export type {
|
|
@@ -347,7 +347,6 @@ module.exports = {
|
|
|
347
347
|
isScalarAndEqual: isScalarAndEqual,
|
|
348
348
|
recycleNodesInto: recycleNodesInto,
|
|
349
349
|
stableCopy: stableCopy,
|
|
350
|
-
getAllRootVariables: getAllRootVariables,
|
|
351
350
|
getFragmentIdentifier: getFragmentIdentifier,
|
|
352
351
|
getRefetchMetadata: getRefetchMetadata,
|
|
353
352
|
getPaginationMetadata: getPaginationMetadata,
|
|
@@ -364,5 +363,6 @@ module.exports = {
|
|
|
364
363
|
getPromiseForActiveRequest: fetchQueryInternal.getPromiseForActiveRequest,
|
|
365
364
|
getObservableForActiveRequest:
|
|
366
365
|
fetchQueryInternal.getObservableForActiveRequest,
|
|
366
|
+
withProvidedVariables: withProvidedVariables,
|
|
367
367
|
},
|
|
368
368
|
};
|
package/lib/index.js
CHANGED
|
@@ -83,8 +83,6 @@ var createPayloadFor3DField = require('./util/createPayloadFor3DField');
|
|
|
83
83
|
|
|
84
84
|
var deepFreeze = require('./util/deepFreeze');
|
|
85
85
|
|
|
86
|
-
var getAllRootVariables = require('./util/getAllRootVariables');
|
|
87
|
-
|
|
88
86
|
var getFragmentIdentifier = require('./util/getFragmentIdentifier');
|
|
89
87
|
|
|
90
88
|
var getPaginationMetadata = require('./util/getPaginationMetadata');
|
|
@@ -123,6 +121,8 @@ var reportMissingRequiredFields = require('./util/reportMissingRequiredFields');
|
|
|
123
121
|
|
|
124
122
|
var stableCopy = require('./util/stableCopy');
|
|
125
123
|
|
|
124
|
+
var withProvidedVariables = require('./util/withProvidedVariables');
|
|
125
|
+
|
|
126
126
|
// As early as possible, check for the existence of the JavaScript globals which
|
|
127
127
|
// Relay Runtime relies upon, and produce a clear message if they do not exist.
|
|
128
128
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -227,7 +227,6 @@ module.exports = {
|
|
|
227
227
|
isScalarAndEqual: isScalarAndEqual,
|
|
228
228
|
recycleNodesInto: recycleNodesInto,
|
|
229
229
|
stableCopy: stableCopy,
|
|
230
|
-
getAllRootVariables: getAllRootVariables,
|
|
231
230
|
getFragmentIdentifier: getFragmentIdentifier,
|
|
232
231
|
getRefetchMetadata: getRefetchMetadata,
|
|
233
232
|
getPaginationMetadata: getPaginationMetadata,
|
|
@@ -242,6 +241,7 @@ module.exports = {
|
|
|
242
241
|
fetchQuery: fetchQueryInternal.fetchQuery,
|
|
243
242
|
fetchQueryDeduped: fetchQueryInternal.fetchQueryDeduped,
|
|
244
243
|
getPromiseForActiveRequest: fetchQueryInternal.getPromiseForActiveRequest,
|
|
245
|
-
getObservableForActiveRequest: fetchQueryInternal.getObservableForActiveRequest
|
|
244
|
+
getObservableForActiveRequest: fetchQueryInternal.getObservableForActiveRequest,
|
|
245
|
+
withProvidedVariables: withProvidedVariables
|
|
246
246
|
}
|
|
247
247
|
};
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var withProvidedVariables = require('../util/withProvidedVariables');
|
|
14
14
|
|
|
15
15
|
var _require = require('./ConvertToExecuteFunction'),
|
|
16
16
|
convertFetch = _require.convertFetch;
|
|
@@ -27,24 +27,24 @@ function create(fetchFn, subscribe) {
|
|
|
27
27
|
var observeFetch = convertFetch(fetchFn);
|
|
28
28
|
|
|
29
29
|
function execute(request, variables, cacheConfig, uploadables, logRequestInfo) {
|
|
30
|
-
var
|
|
30
|
+
var operationVariables = withProvidedVariables(variables, request);
|
|
31
31
|
|
|
32
32
|
if (request.operationKind === 'subscription') {
|
|
33
33
|
!subscribe ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayNetwork: This network layer does not support Subscriptions. ' + 'To use Subscriptions, provide a custom network layer.') : invariant(false) : void 0;
|
|
34
34
|
!!uploadables ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayNetwork: Cannot provide uploadables while subscribing.') : invariant(false) : void 0;
|
|
35
|
-
return subscribe(request,
|
|
35
|
+
return subscribe(request, operationVariables, cacheConfig);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
var pollInterval = cacheConfig.poll;
|
|
39
39
|
|
|
40
40
|
if (pollInterval != null) {
|
|
41
41
|
!!uploadables ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayNetwork: Cannot provide uploadables while polling.') : invariant(false) : void 0;
|
|
42
|
-
return observeFetch(request,
|
|
42
|
+
return observeFetch(request, operationVariables, {
|
|
43
43
|
force: true
|
|
44
44
|
}).poll(pollInterval);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
return observeFetch(request,
|
|
47
|
+
return observeFetch(request, operationVariables, cacheConfig, uploadables, logRequestInfo);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
return {
|
|
@@ -68,9 +68,11 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Determines the variables that are in scope for a given operation given values
|
|
71
|
-
* for some/all of its arguments.
|
|
72
|
-
*
|
|
71
|
+
* for some/all of its arguments.
|
|
72
|
+
* - extraneous input variables are filtered from the output
|
|
73
|
+
* - missing variables are set to default values (if given in the
|
|
73
74
|
* operation's definition).
|
|
75
|
+
* - variables with provider modules are added
|
|
74
76
|
*/
|
|
75
77
|
|
|
76
78
|
|
|
@@ -11,19 +11,19 @@
|
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
function
|
|
14
|
+
function withProvidedVariables(userSuppliedVariables, parameters) {
|
|
15
15
|
var providedVariables = parameters.providedVariables;
|
|
16
16
|
|
|
17
17
|
if (providedVariables != null) {
|
|
18
|
-
var
|
|
19
|
-
Object.assign(
|
|
18
|
+
var operationVariables = {};
|
|
19
|
+
Object.assign(operationVariables, userSuppliedVariables);
|
|
20
20
|
Object.keys(providedVariables).forEach(function (varName) {
|
|
21
|
-
|
|
21
|
+
operationVariables[varName] = providedVariables[varName].get();
|
|
22
22
|
});
|
|
23
|
-
return
|
|
23
|
+
return operationVariables;
|
|
24
24
|
} else {
|
|
25
25
|
return userSuppliedVariables;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
module.exports =
|
|
29
|
+
module.exports = withProvidedVariables;
|
|
@@ -24,7 +24,7 @@ import type {
|
|
|
24
24
|
} from './RelayNetworkTypes';
|
|
25
25
|
import type RelayObservable from './RelayObservable';
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const withProvidedVariables = require('../util/withProvidedVariables');
|
|
28
28
|
const {convertFetch} = require('./ConvertToExecuteFunction');
|
|
29
29
|
const invariant = require('invariant');
|
|
30
30
|
|
|
@@ -46,7 +46,7 @@ function create(
|
|
|
46
46
|
uploadables?: ?UploadableMap,
|
|
47
47
|
logRequestInfo: ?LogRequestInfoFunction,
|
|
48
48
|
): RelayObservable<GraphQLResponse> {
|
|
49
|
-
const
|
|
49
|
+
const operationVariables = withProvidedVariables(variables, request);
|
|
50
50
|
if (request.operationKind === 'subscription') {
|
|
51
51
|
invariant(
|
|
52
52
|
subscribe,
|
|
@@ -58,7 +58,7 @@ function create(
|
|
|
58
58
|
!uploadables,
|
|
59
59
|
'RelayNetwork: Cannot provide uploadables while subscribing.',
|
|
60
60
|
);
|
|
61
|
-
return subscribe(request,
|
|
61
|
+
return subscribe(request, operationVariables, cacheConfig);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
const pollInterval = cacheConfig.poll;
|
|
@@ -67,14 +67,14 @@ function create(
|
|
|
67
67
|
!uploadables,
|
|
68
68
|
'RelayNetwork: Cannot provide uploadables while polling.',
|
|
69
69
|
);
|
|
70
|
-
return observeFetch(request,
|
|
70
|
+
return observeFetch(request, operationVariables, {force: true}).poll(
|
|
71
71
|
pollInterval,
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
return observeFetch(
|
|
76
76
|
request,
|
|
77
|
-
|
|
77
|
+
operationVariables,
|
|
78
78
|
cacheConfig,
|
|
79
79
|
uploadables,
|
|
80
80
|
logRequestInfo,
|