relay-runtime 0.0.0-main-90bee398 → 0.0.0-main-8723bd66

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.
Files changed (44) hide show
  1. package/handlers/connection/ConnectionHandler.js.flow +0 -7
  2. package/handlers/connection/MutationHandlers.js.flow +0 -3
  3. package/index.js +1 -1
  4. package/index.js.flow +7 -0
  5. package/lib/handlers/connection/ConnectionHandler.js +5 -11
  6. package/lib/handlers/connection/MutationHandlers.js +3 -6
  7. package/lib/multi-actor-environment/ActorSpecificEnvironment.js +4 -0
  8. package/lib/multi-actor-environment/MultiActorEnvironment.js +27 -14
  9. package/lib/mutations/commitMutation.js +1 -4
  10. package/lib/network/RelayObservable.js +1 -3
  11. package/lib/store/DataChecker.js +1 -2
  12. package/lib/store/RelayConcreteVariables.js +3 -7
  13. package/lib/store/RelayModernEnvironment.js +55 -31
  14. package/lib/store/RelayModernStore.js +1 -2
  15. package/lib/store/RelayReader.js +1 -2
  16. package/lib/store/RelayReferenceMarker.js +1 -2
  17. package/lib/store/RelayResponseNormalizer.js +1 -2
  18. package/lib/store/RelayStoreUtils.js +1 -2
  19. package/lib/subscription/requestSubscription.js +1 -1
  20. package/lib/util/RelayRuntimeTypes.js +0 -6
  21. package/lib/util/getPaginationVariables.js +2 -3
  22. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +7 -1
  23. package/multi-actor-environment/MultiActorEnvironment.js.flow +25 -0
  24. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +17 -2
  25. package/mutations/commitMutation.js.flow +0 -2
  26. package/network/RelayObservable.js.flow +0 -2
  27. package/package.json +1 -1
  28. package/relay-runtime.js +2 -2
  29. package/relay-runtime.min.js +2 -2
  30. package/store/ClientID.js.flow +1 -1
  31. package/store/DataChecker.js.flow +0 -1
  32. package/store/RelayConcreteVariables.js.flow +0 -5
  33. package/store/RelayModernEnvironment.js.flow +29 -1
  34. package/store/RelayModernStore.js.flow +0 -1
  35. package/store/RelayReader.js.flow +0 -1
  36. package/store/RelayReferenceMarker.js.flow +0 -1
  37. package/store/RelayResponseNormalizer.js.flow +0 -1
  38. package/store/RelayStoreTypes.js.flow +14 -2
  39. package/store/RelayStoreUtils.js.flow +0 -1
  40. package/store/TypeID.js.flow +1 -1
  41. package/subscription/requestSubscription.js.flow +1 -1
  42. package/util/RelayFeatureFlags.js.flow +1 -1
  43. package/util/RelayRuntimeTypes.js.flow +68 -1
  44. package/util/getPaginationVariables.js.flow +0 -2
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow strict
7
+ * @flow strict-local
8
8
  * @format
9
9
  */
10
10
 
@@ -209,7 +209,6 @@ class DataChecker {
209
209
  'RelayAsyncLoader(): Undefined variable `%s`.',
210
210
  name,
211
211
  );
212
- // $FlowFixMe[cannot-write]
213
212
  return this._variables[name];
214
213
  }
215
214
 
@@ -40,7 +40,6 @@ function getFragmentVariables(
40
40
  if (argumentVariables.hasOwnProperty(definition.name)) {
41
41
  return;
42
42
  }
43
- // $FlowFixMe[cannot-spread-interface]
44
43
  variables = variables || {...argumentVariables};
45
44
  switch (definition.kind) {
46
45
  case 'LocalArgument':
@@ -57,12 +56,9 @@ function getFragmentVariables(
57
56
  * RelayStoreUtils.getStableVariableValue() that variable keys are all
58
57
  * present.
59
58
  */
60
- // $FlowFixMe[incompatible-use]
61
59
  variables[definition.name] = undefined;
62
60
  break;
63
61
  }
64
- // $FlowFixMe[incompatible-use]
65
- // $FlowFixMe[cannot-write]
66
62
  variables[definition.name] = rootVariables[definition.name];
67
63
  break;
68
64
  default:
@@ -91,7 +87,6 @@ function getOperationVariables(
91
87
  const operationVariables = {};
92
88
  operation.argumentDefinitions.forEach(def => {
93
89
  let value = def.defaultValue;
94
- // $FlowFixMe[cannot-write]
95
90
  if (variables[def.name] != null) {
96
91
  value = variables[def.name];
97
92
  }
@@ -326,7 +326,7 @@ class RelayModernEnvironment implements IEnvironment {
326
326
 
327
327
  /**
328
328
  * Returns an Observable of GraphQLResponse resulting from executing the
329
- * provided Query or Subscription operation, each result of which is then
329
+ * provided Query operation, each result of which is then
330
330
  * normalized and committed to the publish queue.
331
331
  *
332
332
  * Note: Observables are lazy, so calling this method will do nothing until
@@ -334,6 +334,34 @@ class RelayModernEnvironment implements IEnvironment {
334
334
  */
335
335
  execute({
336
336
  operation,
337
+ }: {|
338
+ operation: OperationDescriptor,
339
+ |}): RelayObservable<GraphQLResponse> {
340
+ return this._execute({
341
+ createSource: () =>
342
+ this._network.execute(
343
+ operation.request.node.params,
344
+ operation.request.variables,
345
+ operation.request.cacheConfig || {},
346
+ null,
347
+ ),
348
+ isClientPayload: false,
349
+ operation,
350
+ optimisticConfig: null,
351
+ updater: null,
352
+ });
353
+ }
354
+
355
+ /**
356
+ * Returns an Observable of GraphQLResponse resulting from executing the
357
+ * provided Subscription operation, each result of which is then
358
+ * normalized and committed to the publish queue.
359
+ *
360
+ * Note: Observables are lazy, so calling this method will do nothing until
361
+ * the result is subscribed to: environment.execute({...}).subscribe({...}).
362
+ */
363
+ executeSubscription({
364
+ operation,
337
365
  updater,
338
366
  }: {|
339
367
  operation: OperationDescriptor,
@@ -713,7 +713,6 @@ function updateTargetFromSource(
713
713
  currentWriteEpoch,
714
714
  );
715
715
  invalidatedRecordIDs.add(dataID);
716
- // $FlowFixMe[incompatible-call]
717
716
  target.set(dataID, nextRecord);
718
717
  });
719
718
  }
@@ -216,7 +216,6 @@ class RelayReader {
216
216
  'RelayReader(): Undefined variable `%s`.',
217
217
  name,
218
218
  );
219
- // $FlowFixMe[cannot-write]
220
219
  return this._variables[name];
221
220
  }
222
221
 
@@ -125,7 +125,6 @@ class RelayReferenceMarker {
125
125
  'RelayReferenceMarker(): Undefined variable `%s`.',
126
126
  name,
127
127
  );
128
- // $FlowFixMe[cannot-write]
129
128
  return this._variables[name];
130
129
  }
131
130
 
@@ -190,7 +190,6 @@ class RelayResponseNormalizer {
190
190
  'RelayResponseNormalizer(): Undefined variable `%s`.',
191
191
  name,
192
192
  );
193
- // $FlowFixMe[cannot-write]
194
193
  return this._variables[name];
195
194
  }
196
195
 
@@ -722,13 +722,25 @@ export interface IEnvironment {
722
722
  * responses may be returned (via `next`) over time followed by either
723
723
  * the request completing (`completed`) or an error (`error`).
724
724
  *
725
+ * Note: Observables are lazy, so calling this method will do nothing until
726
+ * the result is subscribed to: environment.execute({...}).subscribe({...}).
727
+ */
728
+ execute(config: {|
729
+ operation: OperationDescriptor,
730
+ |}): RelayObservable<GraphQLResponse>;
731
+
732
+ /**
733
+ * Send a subscription to the server with Observer semantics: one or more
734
+ * responses may be returned (via `next`) over time followed by either
735
+ * the request completing (`completed`) or an error (`error`).
736
+ *
725
737
  * Networks/servers that support subscriptions may choose to hold the
726
738
  * subscription open indefinitely such that `complete` is not called.
727
739
  *
728
740
  * Note: Observables are lazy, so calling this method will do nothing until
729
- * the result is subscribed to: environment.execute({...}).subscribe({...}).
741
+ * the result is subscribed to: environment.executeSubscription({...}).subscribe({...}).
730
742
  */
731
- execute(config: {|
743
+ executeSubscription(config: {|
732
744
  operation: OperationDescriptor,
733
745
  updater?: ?SelectorStoreUpdater,
734
746
  |}): RelayObservable<GraphQLResponse>;
@@ -186,7 +186,6 @@ function getStableVariableValue(name: string, variables: Variables): mixed {
186
186
  'getVariableValue(): Undefined variable `%s`.',
187
187
  name,
188
188
  );
189
- // $FlowFixMe[cannot-write]
190
189
  return stableCopy(variables[name]);
191
190
  }
192
191
 
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow strict
7
+ * @flow strict-local
8
8
  * @format
9
9
  */
10
10
 
@@ -98,7 +98,7 @@ function requestSubscription<TSubscriptionPayload>(
98
98
  : config;
99
99
 
100
100
  const sub = environment
101
- .execute({
101
+ .executeSubscription({
102
102
  operation,
103
103
  updater,
104
104
  })
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow strict
7
+ * @flow strict-local
8
8
  * @format
9
9
  */
10
10
 
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @flow strict
7
+ * @flow strict-local
8
8
  * @format
9
9
  */
10
10
 
@@ -16,6 +16,9 @@
16
16
  * Basic types used throughout Relay.
17
17
  */
18
18
 
19
+ import type {ReaderFragment, ReaderInlineDataFragment} from './ReaderNode';
20
+ import type {ConcreteRequest} from './RelayConcreteNode';
21
+
19
22
  /**
20
23
  * Represents any resource that must be explicitly disposed of. The most common
21
24
  * use-case is as a return value for subscriptions, where calling `dispose()`
@@ -69,3 +72,67 @@ export type FetchPolicy =
69
72
  | 'store-and-network'
70
73
  | 'store-only';
71
74
  export type RenderPolicy = 'full' | 'partial';
75
+
76
+ /* eslint-disable no-undef */
77
+
78
+ /**
79
+ * Return type of graphql tag literals for all operations.
80
+ */
81
+ declare export opaque type Operation<
82
+ -TVariables: Variables,
83
+ +TData,
84
+ TRawResponse,
85
+ >: ConcreteRequest;
86
+
87
+ /**
88
+ * Return type of graphql tag literals for queries.
89
+ */
90
+ declare export opaque type Query<
91
+ -TVariables: Variables,
92
+ +TData,
93
+ TRawResponse = void,
94
+ >: Operation<TVariables, TData, TRawResponse>;
95
+
96
+ /**
97
+ * Return type of graphql tag literals for mutations.
98
+ */
99
+ declare export opaque type Mutation<
100
+ -TVariables: Variables,
101
+ +TData,
102
+ TRawResponse = void,
103
+ >: Operation<TVariables, TData, TRawResponse>;
104
+
105
+ /**
106
+ * Return type of graphql tag literals for subscriptions.
107
+ *
108
+ * NOTE: Using the GraphQL prefix here because of a naming conflict with
109
+ * `RelayObservable`'s `Subscription` type.
110
+ */
111
+ declare export opaque type GraphQLSubscription<
112
+ -TVariables: Variables,
113
+ +TData,
114
+ TRawResponse = void,
115
+ >: Operation<TVariables, TData, TRawResponse>;
116
+
117
+ /**
118
+ * Return type of graphql tag literals for `@inline` fragments.
119
+ */
120
+ declare export opaque type InlineFragment<
121
+ TFragmentType,
122
+ +TData,
123
+ >: ReaderInlineDataFragment;
124
+
125
+ /**
126
+ * Return type of graphql tag literals for fragments, except `@inline`
127
+ * fragments.
128
+ */
129
+ declare export opaque type Fragment<TFragmentType, +TData>: ReaderFragment;
130
+
131
+ /**
132
+ * Return type of graphql tag literals for `@refetchable` fragments.
133
+ */
134
+ declare export opaque type RefetchableFragment<
135
+ TFragmentType,
136
+ +TData,
137
+ -TVariables: Variables,
138
+ >: Fragment<TFragmentType, TData>;
@@ -56,7 +56,6 @@ function getPaginationVariables(
56
56
  'determined by Relay.',
57
57
  backwardMetadata.count,
58
58
  );
59
- // $FlowFixMe[cannot-spread-interface]
60
59
  const paginationVariables = {
61
60
  ...baseVariables,
62
61
  ...extraVariables,
@@ -93,7 +92,6 @@ function getPaginationVariables(
93
92
  'determined by Relay.',
94
93
  forwardMetadata.count,
95
94
  );
96
- // $FlowFixMe[cannot-spread-interface]
97
95
  const paginationVariables = {
98
96
  ...baseVariables,
99
97
  ...extraVariables,