Fix 400 yoga errors being sent to exception handlers (#5322)

## Context
Yoga can catch its own errors and we don't want to convert them again.
Moreover those errors don't have an "originalError" property and should
be schema related only (400 validation) so we only want to send them
back to the API caller without going through the exception handler.

Also fixed an issue in the createMany which was throwing a 500 when id
was missing from the creation payload. It seems the FE is always sending
an ID but it should actually be optional since the DB can generate one.
This is a regression from the new UUID validation introduced a few weeks
ago.
This commit is contained in:
Weiko
2024-05-07 20:54:10 +02:00
committed by GitHub
parent 6edecf72a0
commit e802cef8f1
2 changed files with 5 additions and 6 deletions

View File

@ -244,7 +244,7 @@ export class WorkspaceQueryRunnerService {
assertMutationNotOnRemoteObject(objectMetadataItem);
args.data.forEach((record) => {
if (record.id) {
if (record?.id) {
assertIsValidUuid(record.id);
}
});

View File

@ -106,12 +106,11 @@ export const useExceptionHandler = <PluginContext extends GraphQLContext>(
...exceptions.unfiltered,
];
const errors = concatenatedErrors.map((err) => {
// Properly convert errors to GraphQLErrors
const graphQLError = convertExceptionToGraphQLError(
err.originalError,
);
if (!err.originalError) {
return err;
}
return graphQLError;
return convertExceptionToGraphQLError(err.originalError);
});
setResult({