Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 27a0623

Browse files
itamarkfacebook-github-bot
authored andcommitted
5/n - Add erroring on seeing relayFieldErrors
Reviewed By: tyao1 Differential Revision: D51944692 fbshipit-source-id: ef0afb0cecbf87228ec2aec283a9754d52b028d1
1 parent 982be71 commit 27a0623

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/relay-runtime/util/handlePotentialSnapshotErrors.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
RelayResolverErrors,
1919
} from '../store/RelayStoreTypes';
2020

21+
import {RelayFieldError} from '../store/RelayErrorTrie';
2122
import RelayFeatureFlags from './RelayFeatureFlags';
2223

2324
function handlePotentialSnapshotErrors(
@@ -34,7 +35,10 @@ function handlePotentialSnapshotErrors(
3435
error: resolverError.error,
3536
});
3637
}
37-
if (RelayFeatureFlags.ENABLE_FIELD_ERROR_HANDLING) {
38+
if (
39+
RelayFeatureFlags.ENABLE_FIELD_ERROR_HANDLING &&
40+
errorResponseFields != null
41+
) {
3842
if (errorResponseFields != null) {
3943
for (const fieldError of errorResponseFields) {
4044
const {path, owner, error} = fieldError;
@@ -47,6 +51,13 @@ function handlePotentialSnapshotErrors(
4751
});
4852
}
4953
}
54+
55+
if (RelayFeatureFlags.ENABLE_FIELD_ERROR_HANDLING_THROW_BY_DEFAULT) {
56+
throw new RelayFieldError(
57+
`Relay: Unexpected response payload - this object includes an errors property in which you can access the underlying errors`,
58+
errorResponseFields.map(({path, owner, error}) => error),
59+
);
60+
}
5061
}
5162

5263
if (missingRequiredFields != null) {

0 commit comments

Comments
 (0)