relay-runtime 0.0.0-main-aa73c44f → 0.0.0-main-03ed79cb

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,7 +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
+ import type {ProvidedVariablesType} from '../util/RelayConcreteNode';
22
22
  import type {Variables} from '../util/RelayRuntimeTypes';
23
23
 
24
24
  const {getArgumentValues} = require('./RelayStoreUtils');
@@ -85,7 +85,7 @@ function getFragmentVariables(
85
85
  */
86
86
  function getOperationVariables(
87
87
  operation: NormalizationOperation,
88
- parameters: RequestParameters,
88
+ providedVariables: ?ProvidedVariablesType,
89
89
  variables: Variables,
90
90
  ): Variables {
91
91
  const operationVariables = {};
@@ -97,7 +97,6 @@ function getOperationVariables(
97
97
  operationVariables[def.name] = value;
98
98
  });
99
99
 
100
- const providedVariables = parameters.providedVariables;
101
100
  if (providedVariables != null) {
102
101
  Object.keys(providedVariables).forEach((varName: string) => {
103
102
  operationVariables[varName] = providedVariables[varName].get();
@@ -46,7 +46,7 @@ function createOperationDescriptor<TQuery: OperationType>(
46
46
  const operation = request.operation;
47
47
  const operationVariables = getOperationVariables(
48
48
  operation,
49
- request.params,
49
+ request.params.providedVariables,
50
50
  variables,
51
51
  );
52
52
  const requestDescriptor = createRequestDescriptor(
@@ -57,8 +57,15 @@ type PendingUpdater = {|
57
57
  +updater: StoreUpdater,
58
58
  |};
59
59
 
60
+ const _global: typeof global | $FlowFixMe =
61
+ typeof global !== 'undefined'
62
+ ? global
63
+ : typeof window !== 'undefined'
64
+ ? window
65
+ : undefined;
66
+
60
67
  const applyWithGuard =
61
- global?.ErrorUtils?.applyWithGuard ??
68
+ _global?.ErrorUtils?.applyWithGuard ??
62
69
  ((callback, context, args, onError, name) => callback.apply(context, args));
63
70
 
64
71
  /**
@@ -35,6 +35,8 @@ export type NormalizationRootNode =
35
35
  | ConcreteRequest
36
36
  | NormalizationSplitOperation;
37
37
 
38
+ export type ProvidedVariablesType = {[key: string]: {|get(): mixed|}};
39
+
38
40
  /**
39
41
  * Contains the parameters required for executing a GraphQL request.
40
42
  * The operation can either be provided as a persisted `id` or `text`. If given
@@ -48,7 +50,7 @@ export type RequestParameters =
48
50
  // common fields
49
51
  +name: string,
50
52
  +operationKind: 'mutation' | 'query' | 'subscription',
51
- +providedVariables?: {[key: string]: {|get(): mixed|}},
53
+ +providedVariables?: ProvidedVariablesType,
52
54
  +metadata: {[key: string]: mixed, ...},
53
55
  |}
54
56
  | {|
@@ -58,7 +60,7 @@ export type RequestParameters =
58
60
  // common fields
59
61
  +name: string,
60
62
  +operationKind: 'mutation' | 'query' | 'subscription',
61
- +providedVariables?: {[key: string]: {|get(): mixed|}},
63
+ +providedVariables?: ProvidedVariablesType,
62
64
  +metadata: {[key: string]: mixed, ...},
63
65
  |};
64
66
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  'use strict';
15
15
 
16
- import type {RequestParameters} from './RelayConcreteNode';
16
+ import type {ProvidedVariablesType} from './RelayConcreteNode';
17
17
  import type {Variables} from './RelayRuntimeTypes';
18
18
 
19
19
  const areEqual = require('areEqual');
@@ -24,9 +24,8 @@ const debugCache = WEAKMAP_SUPPORTED ? new WeakMap() : new Map();
24
24
 
25
25
  function withProvidedVariables(
26
26
  userSuppliedVariables: Variables,
27
- parameters: RequestParameters,
27
+ providedVariables: ?ProvidedVariablesType,
28
28
  ): Variables {
29
- const providedVariables = parameters.providedVariables;
30
29
  if (providedVariables != null) {
31
30
  const operationVariables = {};
32
31
  Object.assign(operationVariables, userSuppliedVariables);