relay-runtime 20.0.0 → 20.1.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/experimental.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v20.0.0
2
+ * Relay v20.1.1
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v20.0.0
2
+ * Relay v20.1.1
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -139,7 +139,7 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
139
139
  this._traverseSelections(selection, record, data);
140
140
  }
141
141
  } else {
142
- var implementsInterface = data.hasOwnProperty(abstractKey);
142
+ var implementsInterface = Object.prototype.hasOwnProperty.call(data, abstractKey);
143
143
  var _typeName = RelayModernRecord.getType(record);
144
144
  var typeID = generateTypeID(_typeName);
145
145
  var typeRecord = this._recordSource.get(typeID);
@@ -157,7 +157,7 @@ var RelayResponseNormalizer = /*#__PURE__*/function () {
157
157
  case 'TypeDiscriminator':
158
158
  {
159
159
  var _abstractKey = selection.abstractKey;
160
- var _implementsInterface = data.hasOwnProperty(_abstractKey);
160
+ var _implementsInterface = Object.prototype.hasOwnProperty.call(data, _abstractKey);
161
161
  var _typeName2 = RelayModernRecord.getType(record);
162
162
  var _typeID = generateTypeID(_typeName2);
163
163
  var _typeRecord = this._recordSource.get(_typeID);
@@ -37,7 +37,7 @@ const validateMutation = require('./validateMutation');
37
37
  const invariant = require('invariant');
38
38
  const warning = require('warning');
39
39
 
40
- export type MutationConfig<TMutation: MutationParameters> = {
40
+ export type MutationConfig<TMutation: MutationParameters> = $ReadOnly<{
41
41
  cacheConfig?: CacheConfig,
42
42
  configs?: Array<DeclarativeMutationConfig>,
43
43
  mutation: GraphQLTaggedNode,
@@ -57,9 +57,9 @@ export type MutationConfig<TMutation: MutationParameters> = {
57
57
  updater?: ?SelectorStoreUpdater<TMutation['response']>,
58
58
  uploadables?: UploadableMap,
59
59
  variables: TMutation['variables'],
60
- };
60
+ }>;
61
61
 
62
- export type CommitMutationConfig<TVariables, TData, TRawResponse> = {
62
+ export type CommitMutationConfig<TVariables, TData, TRawResponse> = $ReadOnly<{
63
63
  cacheConfig?: CacheConfig,
64
64
  configs?: Array<DeclarativeMutationConfig>,
65
65
  mutation: Mutation<TVariables, TData, TRawResponse>,
@@ -71,8 +71,8 @@ export type CommitMutationConfig<TVariables, TData, TRawResponse> = {
71
71
  optimisticUpdater?: ?SelectorStoreUpdater<TData>,
72
72
  updater?: ?SelectorStoreUpdater<TData>,
73
73
  uploadables?: UploadableMap,
74
- variables: TVariables,
75
- };
74
+ variables: NoInfer<TVariables>,
75
+ }>;
76
76
 
77
77
  /**
78
78
  * Higher-level helper function to execute a mutation against a specific
@@ -26,7 +26,7 @@ export interface INetwork {
26
26
 
27
27
  export type LogRequestInfoFunction = mixed => void;
28
28
 
29
- export type PayloadData = {[key: string]: mixed};
29
+ export type PayloadData = {+[key: string]: mixed};
30
30
 
31
31
  export type PayloadError = interface {
32
32
  message: string,
@@ -134,4 +134,4 @@ export type SubscribeFunction = (
134
134
  ) => RelayObservable<GraphQLResponse>;
135
135
 
136
136
  export type Uploadable = File | Blob;
137
- export type UploadableMap = {[key: string]: Uploadable};
137
+ export type UploadableMap = {+[key: string]: Uploadable};
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": "20.0.0",
4
+ "version": "20.1.1",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay"
@@ -115,7 +115,7 @@ const invariant = require('invariant');
115
115
  function fetchQuery<TVariables: Variables, TData, TRawResponse>(
116
116
  environment: IEnvironment,
117
117
  query: Query<TVariables, TData, TRawResponse>,
118
- variables: TVariables,
118
+ variables: NoInfer<TVariables>,
119
119
  options?: $ReadOnly<{
120
120
  fetchPolicy?: FetchQueryFetchPolicy,
121
121
  networkCacheConfig?: CacheConfig,
@@ -443,7 +443,7 @@ function merge(record1: Record, record2: Record): Record {
443
443
  if (ERRORS_KEY in record1 || ERRORS_KEY in record2) {
444
444
  const {[ERRORS_KEY]: errors1, ...fields1} = record1;
445
445
  const {[ERRORS_KEY]: errors2, ...fields2} = record2;
446
- // $FlowIssue[cannot-spread-indexer]
446
+ // $FlowFixMe[cannot-spread-indexer]
447
447
  const updated: Record = {...fields1, ...fields2};
448
448
  if (errors1 == null && errors2 == null) {
449
449
  return updated;
@@ -465,7 +465,7 @@ function merge(record1: Record, record2: Record): Record {
465
465
  }
466
466
  return updated;
467
467
  } else {
468
- // $FlowIssue[cannot-spread-indexer]
468
+ // $FlowFixMe[cannot-spread-indexer]
469
469
  return {...record1, ...record2};
470
470
  }
471
471
  }
@@ -470,6 +470,8 @@ class RelayModernStore implements Store {
470
470
  fetchTime: Date.now(),
471
471
  };
472
472
  this._releaseBuffer.push(id);
473
+ /* $FlowFixMe[incompatible-call] Natural Inference rollout. See
474
+ * https://fburl.com/gdoc/y8dn025u */
473
475
  this._roots.set(id, temporaryRootEntry);
474
476
  }
475
477
  }
@@ -252,7 +252,7 @@ class RelayReader {
252
252
  const owner = this._fragmentName;
253
253
 
254
254
  this._fieldErrors.push(
255
- this._selector.node.metadata?.throwOnFieldError ?? false
255
+ (this._selector.node.metadata?.throwOnFieldError ?? false)
256
256
  ? {
257
257
  kind: 'missing_expected_data.throw',
258
258
  owner,
@@ -86,7 +86,7 @@ class RelayRecordSource implements MutableRecordSource {
86
86
  }
87
87
 
88
88
  toJSON(): RecordSourceJSON {
89
- const obj: RecordSourceJSON = {};
89
+ const obj: {...RecordSourceJSON} = {};
90
90
  for (const [key, record] of this._records) {
91
91
  obj[key] = RelayModernRecord.toJSON<null | void>(record);
92
92
  }
@@ -67,7 +67,7 @@ const invariant = require('invariant');
67
67
  const warning = require('warning');
68
68
 
69
69
  export type GetDataID = (
70
- fieldValue: {[string]: mixed},
70
+ fieldValue: {+[string]: mixed},
71
71
  typeName: string,
72
72
  ) => mixed;
73
73
 
@@ -250,7 +250,11 @@ class RelayResponseNormalizer {
250
250
  this._traverseSelections(selection, record, data);
251
251
  }
252
252
  } else {
253
- const implementsInterface = data.hasOwnProperty(abstractKey);
253
+ // $FlowFixMe[method-unbinding] - data could be prototype less
254
+ const implementsInterface = Object.prototype.hasOwnProperty.call(
255
+ data,
256
+ abstractKey,
257
+ );
254
258
  const typeName = RelayModernRecord.getType(record);
255
259
  const typeID = generateTypeID(typeName);
256
260
  let typeRecord = this._recordSource.get(typeID);
@@ -271,7 +275,11 @@ class RelayResponseNormalizer {
271
275
  }
272
276
  case 'TypeDiscriminator': {
273
277
  const {abstractKey} = selection;
274
- const implementsInterface = data.hasOwnProperty(abstractKey);
278
+ // $FlowFixMe[method-unbinding] - data could be prototype less
279
+ const implementsInterface = Object.prototype.hasOwnProperty.call(
280
+ data,
281
+ abstractKey,
282
+ );
275
283
  const typeName = RelayModernRecord.getType(record);
276
284
  const typeID = generateTypeID(typeName);
277
285
  let typeRecord = this._recordSource.get(typeID);
@@ -245,7 +245,7 @@ export interface RecordSource {
245
245
  /**
246
246
  * A collection of records keyed by id.
247
247
  */
248
- export type RecordSourceJSON = {[DataID]: ?RecordJSON};
248
+ export type RecordSourceJSON = {+[DataID]: ?RecordJSON};
249
249
 
250
250
  /**
251
251
  * A read/write interface for accessing and updating graph data.
@@ -258,10 +258,10 @@ export interface MutableRecordSource extends RecordSource {
258
258
  }
259
259
 
260
260
  export type CheckOptions = {
261
- handlers: $ReadOnlyArray<MissingFieldHandler>,
262
- defaultActorIdentifier: ActorIdentifier,
263
- getTargetForActor: (actorIdentifier: ActorIdentifier) => MutableRecordSource,
264
- getSourceForActor: (actorIdentifier: ActorIdentifier) => RecordSource,
261
+ +handlers: $ReadOnlyArray<MissingFieldHandler>,
262
+ +defaultActorIdentifier: ActorIdentifier,
263
+ +getTargetForActor: (actorIdentifier: ActorIdentifier) => MutableRecordSource,
264
+ +getSourceForActor: (actorIdentifier: ActorIdentifier) => RecordSource,
265
265
  };
266
266
 
267
267
  export type OperationAvailability =
@@ -32,11 +32,11 @@ export type EvaluationResult<T> = {
32
32
  error: ?Error,
33
33
  };
34
34
 
35
- export type ResolverFragmentResult = {
35
+ export type ResolverFragmentResult = $ReadOnly<{
36
36
  data: mixed,
37
37
  isMissingData: boolean,
38
38
  fieldErrors: ?FieldErrors,
39
- };
39
+ }>;
40
40
 
41
41
  export type GetDataForResolverFragmentFn =
42
42
  SingularReaderSelector => ResolverFragmentResult;
@@ -14,7 +14,7 @@
14
14
  const {VIEWER_ID, VIEWER_TYPE} = require('./ViewerPattern');
15
15
 
16
16
  function defaultGetDataID(
17
- fieldValue: {[string]: mixed},
17
+ fieldValue: {+[string]: mixed},
18
18
  typeName: string,
19
19
  ): mixed {
20
20
  if (typeName === VIEWER_TYPE) {
@@ -41,16 +41,17 @@ export type SubscriptionParameters = {
41
41
  * Updated Flow type that makes use of typed graphql tagged literals with
42
42
  * type information.
43
43
  */
44
- export type GraphQLSubscriptionConfig<TVariables, TData, TRawResponse> = {
45
- configs?: Array<DeclarativeMutationConfig>,
46
- cacheConfig?: CacheConfig,
47
- subscription: GraphQLSubscription<TVariables, TData, TRawResponse>,
48
- variables: TVariables,
49
- onCompleted?: ?() => void,
50
- onError?: ?(error: Error) => void,
51
- onNext?: ?(response: ?TData) => void,
52
- updater?: ?SelectorStoreUpdater<TData>,
53
- };
44
+ export type GraphQLSubscriptionConfig<TVariables, TData, TRawResponse> =
45
+ $ReadOnly<{
46
+ configs?: Array<DeclarativeMutationConfig>,
47
+ cacheConfig?: CacheConfig,
48
+ subscription: GraphQLSubscription<TVariables, TData, TRawResponse>,
49
+ variables: TVariables,
50
+ onCompleted?: ?() => void,
51
+ onError?: ?(error: Error) => void,
52
+ onNext?: ?(response: ?TData) => void,
53
+ updater?: ?SelectorStoreUpdater<TData>,
54
+ }>;
54
55
 
55
56
  function requestSubscription<TVariables: Variables, TData, TRawResponse>(
56
57
  environment: IEnvironment,
@@ -62,14 +62,14 @@ export type VariablesOf<T: OperationType> = T['variables'];
62
62
  * a given instance of executing an operation.
63
63
  */
64
64
  export type CacheConfig = {
65
- force?: ?boolean,
66
- poll?: ?number,
67
- liveConfigId?: ?string,
68
- onSubscribe?: () => void,
69
- onResume?: (pauseTimeMs: number) => void,
70
- onPause?: (mqttConnectionIsOk: boolean, internetIsOk: boolean) => void,
71
- metadata?: {[key: string]: mixed, ...},
72
- transactionId?: ?string,
65
+ +force?: ?boolean,
66
+ +poll?: ?number,
67
+ +liveConfigId?: ?string,
68
+ +onSubscribe?: () => void,
69
+ +onResume?: (pauseTimeMs: number) => void,
70
+ +onPause?: (mqttConnectionIsOk: boolean, internetIsOk: boolean) => void,
71
+ +metadata?: {+[key: string]: mixed, ...},
72
+ +transactionId?: ?string,
73
73
  };
74
74
 
75
75
  export type FetchQueryFetchPolicy = 'store-or-network' | 'network-only';