Skip to content

Commit

Permalink
rename errorResponseFields to fieldErrors
Browse files Browse the repository at this point in the history
Reviewed By: evanyeung

Differential Revision: D67923811

fbshipit-source-id: c6ebaec0b39cd9e35e4b62baef3e4e3ce3b861d2
  • Loading branch information
itamark authored and facebook-github-bot committed Jan 8, 2025
1 parent a6fec33 commit 9c87ff6
Show file tree
Hide file tree
Showing 31 changed files with 259 additions and 323 deletions.
8 changes: 4 additions & 4 deletions packages/react-relay/__tests__/LiveResolvers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ test('Errors when reading a @live resolver that does not return a LiveState obje
});

const data = environment.lookup(operation.fragment);
expect(data.errorResponseFields).toEqual([
expect(data.fieldErrors).toEqual([
{
kind: 'relay_resolver.error',
owner: 'LiveResolversTest18Query',
Expand Down Expand Up @@ -1757,7 +1757,7 @@ test('provided variables and resolvers', () => {
});

const snapshot = environment.lookup(operation.fragment);
expect(snapshot.errorResponseFields).toEqual(null);
expect(snapshot.fieldErrors).toEqual(null);
expect(snapshot.data).toEqual({
hello_world_with_provided_variable: 'Hello, Hello, World!!',
});
Expand All @@ -1782,7 +1782,7 @@ test('allows dependencies to be provided through the store', () => {
});

const snapshot = environment.lookup(operation.fragment);
expect(snapshot.errorResponseFields).toEqual(null);
expect(snapshot.fieldErrors).toEqual(null);
expect(snapshot.data).toEqual({
hello_world_with_context: 'Hello Hello Allemaal!!',
});
Expand All @@ -1809,7 +1809,7 @@ test('allows objects to be provided to be provided through the store', () => {
});

const snapshot = environment.lookup(operation.fragment);
expect(snapshot.errorResponseFields).toEqual(null);
expect(snapshot.fieldErrors).toEqual(null);
expect(snapshot.data).toEqual({
hello_world_with_context_object: 'Hello Hello Allemaal!!',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('ReactRelayFragmentContainer with fragment ownership', () => {
},
__fragmentOwner: ownerUser1.request,
},
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
isMissingData: false,
Expand Down Expand Up @@ -333,7 +333,7 @@ describe('ReactRelayFragmentContainer with fragment ownership', () => {
},
__fragmentOwner: ownerUser2.request,
},
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
isMissingData: false,
Expand Down Expand Up @@ -403,7 +403,7 @@ describe('ReactRelayFragmentContainer with fragment ownership', () => {
},
__fragmentOwner: ownerUser1WithCondVar.request,
},
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
isMissingData: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('ReactRelayFragmentContainer', () => {
id: '4',
name: 'Zuck',
},
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
isMissingData: false,
Expand Down Expand Up @@ -371,7 +371,7 @@ describe('ReactRelayFragmentContainer', () => {
name: 'Joe',
},
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down Expand Up @@ -429,7 +429,7 @@ describe('ReactRelayFragmentContainer', () => {
// Name is excluded since value of cond is now false
},
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ describe('ReactRelayPaginationContainer', () => {
expect(environment.subscribe.mock.calls[0][0]).toEqual({
data: expect.any(Object),
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('ReactRelayPaginationContainer', () => {
expect(environment.subscribe.mock.calls[0][0]).toEqual({
data: expect.any(Object),
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down Expand Up @@ -525,7 +525,7 @@ describe('ReactRelayPaginationContainer', () => {
expect(environment.subscribe.mock.calls[0][0]).toEqual({
data: expect.any(Object),
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down Expand Up @@ -629,7 +629,7 @@ describe('ReactRelayPaginationContainer', () => {
expect(environment.subscribe.mock.calls[0][0]).toEqual({
data: expect.any(Object),
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ describe('ReactRelayRefetchContainer', () => {
name: 'Zuck',
},
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down Expand Up @@ -379,7 +379,7 @@ describe('ReactRelayRefetchContainer', () => {
name: 'Joe',
},
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down Expand Up @@ -438,7 +438,7 @@ describe('ReactRelayRefetchContainer', () => {
// Name is excluded since value of cond is now false
},
isMissingData: false,
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
seenRecords: expect.any(Object),
Expand Down Expand Up @@ -524,7 +524,7 @@ describe('ReactRelayRefetchContainer', () => {
id: '4',
// Name is excluded since value of cond is now false
},
errorResponseFields: null,
fieldErrors: null,
missingLiveResolverFields: [],
missingClientEdges: null,
isMissingData: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ test('Errors thrown when reading the model a client edge points to are caught as
{},
);
const snapshot = environment.lookup(operation.fragment);
expect(snapshot.errorResponseFields).toEqual([
expect(snapshot.fieldErrors).toEqual([
{
error: Error(ERROR_MESSAGE),
owner: 'RelayResolverNullableModelClientEdgeTest_ErrorModel_Query',
Expand All @@ -519,7 +519,7 @@ test('Errors thrown when reading plural client edge are caught as resolver error
{},
);
const snapshot = environment.lookup(operation.fragment);
expect(snapshot.errorResponseFields).toEqual([
expect(snapshot.fieldErrors).toEqual([
{
error: Error(ERROR_MESSAGE),
owner: 'RelayResolverNullableModelClientEdgeTest_PluralErrorModel_Query',
Expand Down Expand Up @@ -553,7 +553,7 @@ test('Errors thrown when reading plural client edge are caught as resolver error
{},
);
const snapshot = environment.lookup(operation.fragment);
expect(snapshot.errorResponseFields).toEqual([
expect(snapshot.fieldErrors).toEqual([
{
error: Error(ERROR_MESSAGE),
owner:
Expand Down
9 changes: 3 additions & 6 deletions packages/react-relay/relay-hooks/legacy/FragmentResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,10 @@ class FragmentResourceImpl {
_throwOrLogErrorsInSnapshot(snapshot: SingularOrPluralSnapshot) {
if (Array.isArray(snapshot)) {
snapshot.forEach(s => {
handlePotentialSnapshotErrors(this._environment, s.errorResponseFields);
handlePotentialSnapshotErrors(this._environment, s.fieldErrors);
});
} else {
handlePotentialSnapshotErrors(
this._environment,
snapshot.errorResponseFields,
);
handlePotentialSnapshotErrors(this._environment, snapshot.fieldErrors);
}
}

Expand Down Expand Up @@ -763,7 +760,7 @@ class FragmentResourceImpl {
missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
seenRecords: currentSnapshot.seenRecords,
selector: currentSnapshot.selector,
errorResponseFields: currentSnapshot.errorResponseFields,
fieldErrors: currentSnapshot.fieldErrors,
};
if (updatedData !== renderData) {
const result = getFragmentResult(
Expand Down
7 changes: 2 additions & 5 deletions packages/react-relay/relay-hooks/readFragmentInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,10 @@ function handlePotentialSnapshotErrorsForState(
state: FragmentState,
): void {
if (state.kind === 'singular') {
handlePotentialSnapshotErrors(
environment,
state.snapshot.errorResponseFields,
);
handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors);
} else if (state.kind === 'plural') {
for (const snapshot of state.snapshots) {
handlePotentialSnapshotErrors(environment, snapshot.errorResponseFields);
handlePotentialSnapshotErrors(environment, snapshot.fieldErrors);
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions packages/react-relay/relay-hooks/useFragmentInternal_CURRENT.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,10 @@ function handlePotentialSnapshotErrorsForState(
state: FragmentState,
): void {
if (state.kind === 'singular') {
handlePotentialSnapshotErrors(
environment,
state.snapshot.errorResponseFields,
);
handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors);
} else if (state.kind === 'plural') {
for (const snapshot of state.snapshots) {
handlePotentialSnapshotErrors(environment, snapshot.errorResponseFields);
handlePotentialSnapshotErrors(environment, snapshot.fieldErrors);
}
}
}
Expand Down Expand Up @@ -153,7 +150,7 @@ function handleMissedUpdates(
missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
seenRecords: currentSnapshot.seenRecords,
selector: currentSnapshot.selector,
errorResponseFields: currentSnapshot.errorResponseFields,
fieldErrors: currentSnapshot.fieldErrors,
};
return [
updatedData !== state.snapshot.data,
Expand All @@ -177,7 +174,7 @@ function handleMissedUpdates(
missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
seenRecords: currentSnapshot.seenRecords,
selector: currentSnapshot.selector,
errorResponseFields: currentSnapshot.errorResponseFields,
fieldErrors: currentSnapshot.fieldErrors,
};
if (updatedData !== snapshot.data) {
didMissUpdates = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,10 @@ function handlePotentialSnapshotErrorsForState(
state: FragmentState,
): void {
if (state.kind === 'singular') {
handlePotentialSnapshotErrors(
environment,
state.snapshot.errorResponseFields,
);
handlePotentialSnapshotErrors(environment, state.snapshot.fieldErrors);
} else if (state.kind === 'plural') {
for (const snapshot of state.snapshots) {
handlePotentialSnapshotErrors(environment, snapshot.errorResponseFields);
handlePotentialSnapshotErrors(environment, snapshot.fieldErrors);
}
}
}
Expand Down Expand Up @@ -173,7 +170,7 @@ function handleMissedUpdates(
missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
seenRecords: currentSnapshot.seenRecords,
selector: currentSnapshot.selector,
errorResponseFields: currentSnapshot.errorResponseFields,
fieldErrors: currentSnapshot.fieldErrors,
};
return [
updatedData !== state.snapshot.data,
Expand All @@ -199,7 +196,7 @@ function handleMissedUpdates(
missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
seenRecords: currentSnapshot.seenRecords,
selector: currentSnapshot.selector,
errorResponseFields: currentSnapshot.errorResponseFields,
fieldErrors: currentSnapshot.fieldErrors,
};
if (updatedData !== snapshot.data) {
didMissUpdates = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/relay-runtime/query/fetchQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function fetchQuery<TVariables: Variables, TData, TRawResponse>(
const fetchPolicy = options?.fetchPolicy ?? 'network-only';

function readData(snapshot: Snapshot): TData {
handlePotentialSnapshotErrors(environment, snapshot.errorResponseFields);
handlePotentialSnapshotErrors(environment, snapshot.fieldErrors);
/* $FlowFixMe[incompatible-return] we assume readData returns the right
* data just having written it from network or checked availability. */
return snapshot.data;
Expand Down
12 changes: 6 additions & 6 deletions packages/relay-runtime/store/RelayModernFragmentSpecResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import type {ConcreteRequest} from '../util/RelayConcreteNode';
import type {Disposable, Variables} from '../util/RelayRuntimeTypes';
import type {
ErrorResponseFields,
FieldErrors,
FragmentMap,
FragmentSpecResolver,
FragmentSpecResults,
Expand Down Expand Up @@ -228,7 +228,7 @@ class SelectorResolver {
_data: ?SelectorData;
_environment: IEnvironment;
_isMissingData: boolean;
_errorResponseFields: ?ErrorResponseFields;
_fieldErrors: ?FieldErrors;
_rootIsQueryRenderer: boolean;
_selector: SingularReaderSelector;
_subscription: ?Disposable;
Expand All @@ -244,7 +244,7 @@ class SelectorResolver {
this._callback = callback;
this._data = snapshot.data;
this._isMissingData = snapshot.isMissingData;
this._errorResponseFields = snapshot.errorResponseFields;
this._fieldErrors = snapshot.fieldErrors;
this._environment = environment;
this._rootIsQueryRenderer = rootIsQueryRenderer;
this._selector = selector;
Expand Down Expand Up @@ -325,7 +325,7 @@ class SelectorResolver {
}
}
}
handlePotentialSnapshotErrors(this._environment, this._errorResponseFields);
handlePotentialSnapshotErrors(this._environment, this._fieldErrors);
return this._data;
}

Expand All @@ -340,7 +340,7 @@ class SelectorResolver {
const snapshot = this._environment.lookup(selector);
this._data = recycleNodesInto(this._data, snapshot.data);
this._isMissingData = snapshot.isMissingData;
this._errorResponseFields = snapshot.errorResponseFields;
this._fieldErrors = snapshot.fieldErrors;
this._selector = selector;
this._subscription = this._environment.subscribe(snapshot, this._onChange);
}
Expand Down Expand Up @@ -376,7 +376,7 @@ class SelectorResolver {
_onChange = (snapshot: Snapshot): void => {
this._data = snapshot.data;
this._isMissingData = snapshot.isMissingData;
this._errorResponseFields = snapshot.errorResponseFields;
this._fieldErrors = snapshot.fieldErrors;
this._callback();
};
}
Expand Down
Loading

0 comments on commit 9c87ff6

Please sign in to comment.