relay-runtime 0.0.0-main-e8bf0b68 → 0.0.0-main-77073a22

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-e8bf0b68
2
+ * Relay v0.0.0-main-77073a22
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js.flow CHANGED
@@ -51,6 +51,7 @@ 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');
54
55
  const getFragmentIdentifier = require('./util/getFragmentIdentifier');
55
56
  const getPaginationMetadata = require('./util/getPaginationMetadata');
56
57
  const getPaginationVariables = require('./util/getPaginationVariables');
@@ -346,6 +347,7 @@ module.exports = {
346
347
  isScalarAndEqual: isScalarAndEqual,
347
348
  recycleNodesInto: recycleNodesInto,
348
349
  stableCopy: stableCopy,
350
+ getAllRootVariables: getAllRootVariables,
349
351
  getFragmentIdentifier: getFragmentIdentifier,
350
352
  getRefetchMetadata: getRefetchMetadata,
351
353
  getPaginationMetadata: getPaginationMetadata,
package/lib/index.js CHANGED
@@ -83,6 +83,8 @@ var createPayloadFor3DField = require('./util/createPayloadFor3DField');
83
83
 
84
84
  var deepFreeze = require('./util/deepFreeze');
85
85
 
86
+ var getAllRootVariables = require('./util/getAllRootVariables');
87
+
86
88
  var getFragmentIdentifier = require('./util/getFragmentIdentifier');
87
89
 
88
90
  var getPaginationMetadata = require('./util/getPaginationMetadata');
@@ -225,6 +227,7 @@ module.exports = {
225
227
  isScalarAndEqual: isScalarAndEqual,
226
228
  recycleNodesInto: recycleNodesInto,
227
229
  stableCopy: stableCopy,
230
+ getAllRootVariables: getAllRootVariables,
228
231
  getFragmentIdentifier: getFragmentIdentifier,
229
232
  getRefetchMetadata: getRefetchMetadata,
230
233
  getPaginationMetadata: getPaginationMetadata,
@@ -10,6 +10,8 @@
10
10
  // flowlint ambiguous-object-type:error
11
11
  'use strict';
12
12
 
13
+ var getAllRootVariables = require('../util/getAllRootVariables');
14
+
13
15
  var _require = require('./ConvertToExecuteFunction'),
14
16
  convertFetch = _require.convertFetch;
15
17
 
@@ -25,22 +27,24 @@ function create(fetchFn, subscribe) {
25
27
  var observeFetch = convertFetch(fetchFn);
26
28
 
27
29
  function execute(request, variables, cacheConfig, uploadables, logRequestInfo) {
30
+ var withProvidedVariables = getAllRootVariables(variables, request);
31
+
28
32
  if (request.operationKind === 'subscription') {
29
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;
30
34
  !!uploadables ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayNetwork: Cannot provide uploadables while subscribing.') : invariant(false) : void 0;
31
- return subscribe(request, variables, cacheConfig);
35
+ return subscribe(request, withProvidedVariables, cacheConfig);
32
36
  }
33
37
 
34
38
  var pollInterval = cacheConfig.poll;
35
39
 
36
40
  if (pollInterval != null) {
37
41
  !!uploadables ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayNetwork: Cannot provide uploadables while polling.') : invariant(false) : void 0;
38
- return observeFetch(request, variables, {
42
+ return observeFetch(request, withProvidedVariables, {
39
43
  force: true
40
44
  }).poll(pollInterval);
41
45
  }
42
46
 
43
- return observeFetch(request, variables, cacheConfig, uploadables, logRequestInfo);
47
+ return observeFetch(request, withProvidedVariables, cacheConfig, uploadables, logRequestInfo);
44
48
  }
45
49
 
46
50
  return {
@@ -74,7 +74,7 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
74
74
  */
75
75
 
76
76
 
77
- function getOperationVariables(operation, variables) {
77
+ function getOperationVariables(operation, parameters, variables) {
78
78
  var operationVariables = {};
79
79
  operation.argumentDefinitions.forEach(function (def) {
80
80
  var value = def.defaultValue;
@@ -85,6 +85,14 @@ function getOperationVariables(operation, variables) {
85
85
 
86
86
  operationVariables[def.name] = value;
87
87
  });
88
+ var providedVariables = parameters.providedVariables;
89
+
90
+ if (providedVariables != null) {
91
+ Object.keys(providedVariables).forEach(function (varName) {
92
+ operationVariables[varName] = providedVariables[varName].get();
93
+ });
94
+ }
95
+
88
96
  return operationVariables;
89
97
  }
90
98
 
@@ -34,7 +34,7 @@ var _require3 = require('./RelayStoreUtils'),
34
34
  function createOperationDescriptor(request, variables, cacheConfig) {
35
35
  var dataID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ROOT_ID;
36
36
  var operation = request.operation;
37
- var operationVariables = getOperationVariables(operation, variables);
37
+ var operationVariables = getOperationVariables(operation, request.params, variables);
38
38
  var requestDescriptor = createRequestDescriptor(request, operationVariables, cacheConfig);
39
39
  var operationDescriptor = {
40
40
  fragment: createReaderSelector(request.fragment, dataID, operationVariables, requestDescriptor),
@@ -24,6 +24,7 @@ import type {
24
24
  } from './RelayNetworkTypes';
25
25
  import type RelayObservable from './RelayObservable';
26
26
 
27
+ const getAllRootVariables = require('../util/getAllRootVariables');
27
28
  const {convertFetch} = require('./ConvertToExecuteFunction');
28
29
  const invariant = require('invariant');
29
30
 
@@ -45,6 +46,7 @@ function create(
45
46
  uploadables?: ?UploadableMap,
46
47
  logRequestInfo: ?LogRequestInfoFunction,
47
48
  ): RelayObservable<GraphQLResponse> {
49
+ const withProvidedVariables = getAllRootVariables(variables, request);
48
50
  if (request.operationKind === 'subscription') {
49
51
  invariant(
50
52
  subscribe,
@@ -56,7 +58,7 @@ function create(
56
58
  !uploadables,
57
59
  'RelayNetwork: Cannot provide uploadables while subscribing.',
58
60
  );
59
- return subscribe(request, variables, cacheConfig);
61
+ return subscribe(request, withProvidedVariables, cacheConfig);
60
62
  }
61
63
 
62
64
  const pollInterval = cacheConfig.poll;
@@ -65,12 +67,14 @@ function create(
65
67
  !uploadables,
66
68
  'RelayNetwork: Cannot provide uploadables while polling.',
67
69
  );
68
- return observeFetch(request, variables, {force: true}).poll(pollInterval);
70
+ return observeFetch(request, withProvidedVariables, {force: true}).poll(
71
+ pollInterval,
72
+ );
69
73
  }
70
74
 
71
75
  return observeFetch(
72
76
  request,
73
- variables,
77
+ withProvidedVariables,
74
78
  cacheConfig,
75
79
  uploadables,
76
80
  logRequestInfo,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "relay-runtime",
3
3
  "description": "A core runtime for building GraphQL-driven applications.",
4
- "version": "0.0.0-main-e8bf0b68",
4
+ "version": "0.0.0-main-77073a22",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay"