relay-runtime 0.0.0-main-2f997ba5 → 0.0.0-main-e133fea3
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 +1 -1
- package/index.js +1 -1
- package/lib/store/RelayReader.js +4 -5
- package/lib/util/handlePotentialSnapshotErrors.js +1 -6
- package/package.json +1 -1
- package/relay-runtime-experimental.js +1 -1
- package/relay-runtime-experimental.min.js +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayReader.js.flow +4 -2
- package/store/RelayStoreTypes.js.flow +111 -90
- package/util/handlePotentialSnapshotErrors.js.flow +1 -6
|
@@ -355,7 +355,7 @@ class RelayReader {
|
|
|
355
355
|
for (let i = 0; i < this._resolverErrors.length; i++) {
|
|
356
356
|
const resolverError = this._resolverErrors[i];
|
|
357
357
|
errors.push({
|
|
358
|
-
message: `Relay: Error in resolver for field at ${resolverError.
|
|
358
|
+
message: `Relay: Error in resolver for field at ${resolverError.fieldPath} in ${resolverError.owner}`,
|
|
359
359
|
});
|
|
360
360
|
}
|
|
361
361
|
}
|
|
@@ -776,7 +776,9 @@ class RelayReader {
|
|
|
776
776
|
// to be logged.
|
|
777
777
|
if (resolverError) {
|
|
778
778
|
this._resolverErrors.push({
|
|
779
|
-
|
|
779
|
+
kind: 'relay_resolver.error',
|
|
780
|
+
fieldPath,
|
|
781
|
+
owner: this._fragmentName,
|
|
780
782
|
error: resolverError,
|
|
781
783
|
});
|
|
782
784
|
}
|
|
@@ -149,12 +149,7 @@ export type MissingClientEdgeRequestInfo = {
|
|
|
149
149
|
+clientEdgeDestinationID: DataID,
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
export type
|
|
153
|
-
field: FieldLocation,
|
|
154
|
-
error: Error,
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export type RelayResolverErrors = Array<RelayResolverError>;
|
|
152
|
+
export type RelayResolverErrors = Array<RelayResolverErrorEvent>;
|
|
158
153
|
|
|
159
154
|
export type MissingLiveResolverField = {
|
|
160
155
|
+path: string,
|
|
@@ -1260,95 +1255,121 @@ export type MissingFieldHandler =
|
|
|
1260
1255
|
) => ?Array<?DataID>,
|
|
1261
1256
|
};
|
|
1262
1257
|
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1258
|
+
/**
|
|
1259
|
+
* Data which Relay expected to be in the store (because it was requested by
|
|
1260
|
+
* the parent query/mutation/subscription) was missing. This can happen due
|
|
1261
|
+
* to graph relationship changes observed by other queries/mutations, or
|
|
1262
|
+
* imperative updates that don't provide all needed data.
|
|
1263
|
+
*
|
|
1264
|
+
* https://relay.dev/docs/next/debugging/why-null/#graph-relationship-change
|
|
1265
|
+
*
|
|
1266
|
+
* In this case Relay will render with the referenced field as `undefined`.
|
|
1267
|
+
*
|
|
1268
|
+
* __NOTE__: This may break with the type contract of Relay's generated types.
|
|
1269
|
+
*
|
|
1270
|
+
* To turn this into a hard error for a given fragment/query, you can use
|
|
1271
|
+
* `@throwOnFieldError`.
|
|
1272
|
+
*
|
|
1273
|
+
* https://relay.dev/docs/next/guides/throw-on-field-error-directive/
|
|
1274
|
+
*/
|
|
1275
|
+
export type MissingExpectedDataLogEvent = {
|
|
1276
|
+
+kind: 'missing_expected_data.log',
|
|
1277
|
+
+owner: string,
|
|
1278
|
+
+fieldPath: string,
|
|
1279
|
+
};
|
|
1282
1280
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1281
|
+
/**
|
|
1282
|
+
* Data which Relay expected to be in the store (because it was requested by
|
|
1283
|
+
* the parent query/mutation/subscription) was missing. This can happen due
|
|
1284
|
+
* to graph relationship changes observed by other queries/mutations, or
|
|
1285
|
+
* imperative updates that don't provide all needed data.
|
|
1286
|
+
*
|
|
1287
|
+
* https://relay.dev/docs/next/debugging/why-null/#graph-relationship-change
|
|
1288
|
+
*
|
|
1289
|
+
* This event is as `.throw` because the missing data was encountered in a
|
|
1290
|
+
* query/fragment/mutation with `@throwOnFieldError` `@throwOnFieldError`.
|
|
1291
|
+
*
|
|
1292
|
+
* https://relay.dev/docs/next/guides/throw-on-field-error-directive/
|
|
1293
|
+
*
|
|
1294
|
+
* Relay will throw immediately after logging this event. If you wish to
|
|
1295
|
+
* customize the error being thrown, you may throw your own error.
|
|
1296
|
+
*/
|
|
1297
|
+
export type MissingExpectedDataThrowEvent = {
|
|
1298
|
+
+kind: 'missing_expected_data.throw',
|
|
1299
|
+
+owner: string,
|
|
1300
|
+
+fieldPath: string,
|
|
1301
|
+
};
|
|
1300
1302
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1303
|
+
/**
|
|
1304
|
+
* A field was marked as @required(action: LOG) but was null or missing in the
|
|
1305
|
+
* store.
|
|
1306
|
+
*/
|
|
1307
|
+
export type MissingFieldLogEvent = {
|
|
1308
|
+
+kind: 'missing_required_field.log',
|
|
1309
|
+
+owner: string,
|
|
1310
|
+
+fieldPath: string,
|
|
1311
|
+
};
|
|
1306
1312
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1313
|
+
/**
|
|
1314
|
+
* A field was marked as @required(action: THROW) but was null or missing in the
|
|
1315
|
+
* store.
|
|
1316
|
+
*
|
|
1317
|
+
* Relay will throw immediately after logging this event. If you wish to
|
|
1318
|
+
* customize the error being thrown, you may throw your own error.
|
|
1319
|
+
*/
|
|
1320
|
+
export type MissingFieldThrowEvent = {
|
|
1321
|
+
+kind: 'missing_required_field.throw',
|
|
1322
|
+
+owner: string,
|
|
1323
|
+
+fieldPath: string,
|
|
1324
|
+
};
|
|
1315
1325
|
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1326
|
+
/**
|
|
1327
|
+
* A Relay Resolver that is currently being read threw a JavaScript error when
|
|
1328
|
+
* it was last evaluated. By default, the value has been coerced to null and
|
|
1329
|
+
* passed to the product code.
|
|
1330
|
+
*
|
|
1331
|
+
* If `@throwOnFieldError` was used on the parent query/fragment/mutation, you
|
|
1332
|
+
* will also receive a TODO
|
|
1333
|
+
*/
|
|
1334
|
+
export type RelayResolverErrorEvent = {
|
|
1335
|
+
+kind: 'relay_resolver.error',
|
|
1336
|
+
+owner: string,
|
|
1337
|
+
+fieldPath: string,
|
|
1338
|
+
+error: Error,
|
|
1339
|
+
};
|
|
1330
1340
|
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* A field being read by Relay was marked as being in an error state by the
|
|
1343
|
+
* GraphQL response.
|
|
1344
|
+
*
|
|
1345
|
+
* https://spec.graphql.org/October2021/#sec-Errors.Field-errors
|
|
1346
|
+
*
|
|
1347
|
+
* If the field's parent query/fragment/mutation was annotated with
|
|
1348
|
+
* `@throwOnFieldError` and no `@catch` directive was used to catch the error,
|
|
1349
|
+
* Relay will throw an error immediately after logging this event.
|
|
1350
|
+
*
|
|
1351
|
+
* https://relay.dev/docs/next/guides/catch-directive/
|
|
1352
|
+
* https://relay.dev/docs/next/guides/throw-on-field-error-directive/
|
|
1353
|
+
*/
|
|
1354
|
+
export type RelayFieldPayloadErrorEvent = {
|
|
1355
|
+
+kind: 'relay_field_payload.error',
|
|
1356
|
+
+owner: string,
|
|
1357
|
+
+fieldPath: string,
|
|
1358
|
+
+error: TRelayFieldError,
|
|
1359
|
+
// TODO: Should we add `shouldThrow` as a flag here, or perhaps have two
|
|
1360
|
+
// different event types?
|
|
1361
|
+
};
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* Union of all RelayFieldLoggerEvent types
|
|
1365
|
+
*/
|
|
1366
|
+
export type RelayFieldLoggerEvent =
|
|
1367
|
+
| MissingExpectedDataLogEvent
|
|
1368
|
+
| MissingExpectedDataThrowEvent
|
|
1369
|
+
| MissingFieldLogEvent
|
|
1370
|
+
| MissingFieldThrowEvent
|
|
1371
|
+
| RelayResolverErrorEvent
|
|
1372
|
+
| RelayFieldPayloadErrorEvent;
|
|
1352
1373
|
|
|
1353
1374
|
/**
|
|
1354
1375
|
* A handler for events related to @required fields. Currently reports missing
|
|
@@ -27,12 +27,7 @@ function handleResolverErrors(
|
|
|
27
27
|
throwOnFieldError: boolean,
|
|
28
28
|
) {
|
|
29
29
|
for (const resolverError of relayResolverErrors) {
|
|
30
|
-
environment.relayFieldLogger(
|
|
31
|
-
kind: 'relay_resolver.error',
|
|
32
|
-
owner: resolverError.field.owner,
|
|
33
|
-
fieldPath: resolverError.field.path,
|
|
34
|
-
error: resolverError.error,
|
|
35
|
-
});
|
|
30
|
+
environment.relayFieldLogger(resolverError);
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
if (
|