Skip to content

Commit 5dfb88b

Browse files
captbaritonefacebook-github-bot
authored andcommitted
Simplify what we keep in the store for resolver errors
Reviewed By: josephsavona Differential Revision: D46499963 Privacy Context Container: L1125407 fbshipit-source-id: 6d94ebd16f0e1542936543ee76568f13fe88917d
1 parent feaba45 commit 5dfb88b

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

packages/relay-runtime/store/RelayReader.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ class RelayReader {
577577
field,
578578
this._variables,
579579
key,
580-
this._fragmentName,
581580
);
582581
return {
583582
resolverResult,
@@ -590,7 +589,6 @@ class RelayReader {
590589
field,
591590
this._variables,
592591
null,
593-
this._fragmentName,
594592
);
595593
return {
596594
resolverResult,
@@ -646,7 +644,10 @@ class RelayReader {
646644
// the errors can be attached to this read's snapshot. This allows the error
647645
// to be logged.
648646
if (resolverError) {
649-
this._resolverErrors.push(resolverError);
647+
this._resolverErrors.push({
648+
field: {path: field.path, owner: this._fragmentName},
649+
error: resolverError,
650+
});
650651
}
651652

652653
// The resolver itself creates a record in the store. We record that we've
@@ -1175,8 +1176,7 @@ function getResolverValue(
11751176
field: ReaderRelayResolver | ReaderRelayLiveResolver,
11761177
variables: Variables,
11771178
fragmentKey: mixed,
1178-
ownerName: string,
1179-
) {
1179+
): [mixed, ?Error] {
11801180
// Support for languages that work (best) with ES6 modules, such as TypeScript.
11811181
const resolverFunction =
11821182
typeof field.resolverModule === 'function'
@@ -1201,12 +1201,7 @@ function getResolverValue(
12011201
if (e === RESOLVER_FRAGMENT_MISSING_DATA_SENTINEL) {
12021202
resolverResult = undefined;
12031203
} else {
1204-
// `field.path` is typed as nullable while we rollout compiler changes.
1205-
const path = field.path ?? '[UNKNOWN]';
1206-
resolverError = {
1207-
field: {path, owner: ownerName},
1208-
error: e,
1209-
};
1204+
resolverError = e;
12101205
}
12111206
}
12121207
return [resolverResult, resolverError];

packages/relay-runtime/store/ResolverCache.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import type {
2020
DataIDSet,
2121
MutableRecordSource,
2222
Record,
23-
RelayResolverError,
2423
SingularReaderSelector,
2524
Snapshot,
2625
} from './RelayStoreTypes';
@@ -44,7 +43,7 @@ type ResolverID = string;
4443
export type EvaluationResult<T> = {
4544
resolverResult: ?T,
4645
snapshot: ?Snapshot,
47-
error: ?RelayResolverError,
46+
error: ?Error,
4847
};
4948

5049
export type ResolverFragmentResult = {
@@ -65,7 +64,7 @@ export interface ResolverCache {
6564
): [
6665
?T /* Answer */,
6766
?DataID /* Seen record */,
68-
?RelayResolverError,
67+
?Error,
6968
?Snapshot,
7069
?DataID /* ID of record containing a suspended Live field */,
7170
?DataIDSet /** Set of updated records after read. Then need to be consumed by `processFollowupUpdates` */,
@@ -90,7 +89,7 @@ class NoopResolverCache implements ResolverCache {
9089
): [
9190
?T /* Answer */,
9291
?DataID /* Seen record */,
93-
?RelayResolverError,
92+
?Error,
9493
?Snapshot,
9594
?DataID /* ID of record containing a suspended Live field */,
9695
?DataIDSet /** Set of dirty records after read */,
@@ -147,7 +146,7 @@ class RecordResolverCache implements ResolverCache {
147146
): [
148147
?T /* Answer */,
149148
?DataID /* Seen record */,
150-
?RelayResolverError,
149+
?Error,
151150
?Snapshot,
152151
?DataID /* ID of record containing a suspended Live field */,
153152
?DataIDSet /** Set of dirty records after read */,
@@ -228,7 +227,7 @@ class RecordResolverCache implements ResolverCache {
228227
// $FlowFixMe[incompatible-type] - casting mixed
229228
const snapshot: ?Snapshot = linkedRecord[RELAY_RESOLVER_SNAPSHOT_KEY];
230229
// $FlowFixMe[incompatible-type] - casting mixed
231-
const error: ?RelayResolverError = linkedRecord[RELAY_RESOLVER_ERROR_KEY];
230+
const error: ?Error = linkedRecord[RELAY_RESOLVER_ERROR_KEY];
232231

233232
return [answer, linkedID, error, snapshot, undefined, undefined];
234233
}

packages/relay-runtime/store/experimental-live-resolvers/LiveResolverCache.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import type {
2323
MutableRecordSource,
2424
Record,
2525
RecordSource,
26-
RelayResolverError,
2726
SingularReaderSelector,
2827
Snapshot,
2928
} from '../RelayStoreTypes';
@@ -115,7 +114,7 @@ class LiveResolverCache implements ResolverCache {
115114
): [
116115
?T /* Answer */,
117116
?DataID /* Seen record */,
118-
?RelayResolverError,
117+
?Error,
119118
?Snapshot,
120119
?DataID /* ID of record containing a suspended Live field */,
121120
?DataIDSet /** Set of dirty records after read */,
@@ -292,7 +291,7 @@ class LiveResolverCache implements ResolverCache {
292291
// $FlowFixMe[incompatible-type] - casting mixed
293292
const snapshot: ?Snapshot = linkedRecord[RELAY_RESOLVER_SNAPSHOT_KEY];
294293
// $FlowFixMe[incompatible-type] - casting mixed
295-
const error: ?RelayResolverError = linkedRecord[RELAY_RESOLVER_ERROR_KEY];
294+
const error: ?Error = linkedRecord[RELAY_RESOLVER_ERROR_KEY];
296295

297296
let suspenseID = null;
298297

0 commit comments

Comments
 (0)