fix workspace-member deletion with existing attachments/documents (#5232)

## Context
We have a non-nullable constraint on authorId in attachments and
documents, until we have soft-deletion we need to handle deletion of
workspace-members and their attachments/documents.
This PR introduces pre-hooks to deleteOne/deleteMany
This is called when a user deletes a workspace-member from the members
page

Next: needs to be done on user level as well. This is called when users
try to delete their own accounts. I've seen other issues such as
re-creating a user with a previously used email failing.
This commit is contained in:
Weiko
2024-05-02 17:36:57 +02:00
committed by GitHub
parent f9c19c839b
commit fe758e193f
13 changed files with 166 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import {
ValidationError,
NotFoundError,
ConflictError,
MethodNotAllowedError,
} from 'src/engine/utils/graphql-errors.util';
import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
@ -17,6 +18,7 @@ const graphQLPredefinedExceptions = {
401: AuthenticationError,
403: ForbiddenError,
404: NotFoundError,
405: MethodNotAllowedError,
409: ConflictError,
};

View File

@ -142,6 +142,14 @@ export class NotFoundError extends BaseGraphQLError {
}
}
export class MethodNotAllowedError extends BaseGraphQLError {
constructor(message: string, extensions?: Record<string, any>) {
super(message, 'METHOD_NOT_ALLOWED', extensions);
Object.defineProperty(this, 'name', { value: 'MethodNotAllowedError' });
}
}
export class ConflictError extends BaseGraphQLError {
constructor(message: string, extensions?: Record<string, any>) {
super(message, 'CONFLICT', extensions);