Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DestroyMany to graphql query runner #7507

Merged
merged 4 commits into from
Oct 8, 2024

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Oct 8, 2024

Context

destroyMany was not implemented, this PR adds it

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request introduces a new 'destroyMany' operation to the GraphQL query runner, enabling bulk deletion of records. The changes are consistent with the existing codebase structure but introduce more powerful deletion capabilities.

  • Added new GraphqlQueryDestroyManyResolverService for handling bulk deletions in /packages/twenty-server/src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-destroy-many-resolver.service.ts
  • Implemented 'destroyMany' method in GraphqlQueryRunnerService class in /packages/twenty-server/src/engine/api/graphql/graphql-query-runner/graphql-query-runner.service.ts
  • Updated GraphqlQueryResolverFactory to support 'destroyMany' operation in /packages/twenty-server/src/engine/api/graphql/graphql-query-runner/factories/graphql-query-resolver.factory.ts
  • Introduced feature flag 'IsQueryRunnerTwentyORMEnabled' for conditional usage of new GraphQL query runner service in /packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/destroy-many-resolver.factory.ts
  • Refactored GraphqlQueryDestroyOneResolverService for improved error handling and relation processing in /packages/twenty-server/src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-destroy-one-resolver.service.ts

7 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings

Comment on lines +75 to +85
if (relations) {
await processNestedRelationsHelper.processNestedRelations(
objectMetadataMap,
objectMetadataMapItem,
deletedRecords,
relations,
QUERY_MAX_RECORDS,
authContext,
dataSource,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Processing nested relations after deletion might lead to inconsistencies. Consider handling this before deletion or removing it if not necessary

Comment on lines +84 to +94
if (relations) {
await processNestedRelationsHelper.processNestedRelations(
objectMetadataMap,
objectMetadataMapItem,
[recordBeforeDeletion],
relations,
QUERY_MAX_RECORDS,
authContext,
dataSource,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Processing nested relations after deletion might lead to inconsistencies if related records were also deleted. Consider handling this scenario.

Comment on lines 99 to 104
return typeORMObjectRecordsParser.processRecord(
recordBeforeDeletion,
objectMetadataMapItem.nameSingular,
1,
1,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Hardcoding '1' for totalCount and pageCount may be incorrect if used in pagination context. Consider using actual values or removing if unnecessary.

@charlesBochet charlesBochet merged commit d5bd320 into main Oct 8, 2024
8 checks passed
@charlesBochet charlesBochet deleted the c--add-destroy-many-to-graphql-query-runner branch October 8, 2024 15:40
harshit078 pushed a commit to harshit078/twenty that referenced this pull request Oct 14, 2024
## Context
destroyMany was not implemented, this PR adds it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants