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

Fix queryRunnerArgsFactory for updateMany resolver #10322

Merged
merged 2 commits into from
Feb 19, 2025
Merged

Conversation

ijreilly
Copy link
Collaborator

This was updated a few weeks ago and went unnoticed since 1) integration tests were broken + 2) we don't have actionnable updateMany mutations in the product at the moment

It will fix some tests, at least all-people-resolvers.integration-spec.ts for instance

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

Fixed a critical bug in the UpdateMany resolver's data handling within the QueryRunnerArgsFactory, affecting bulk update operations.

  • Modified packages/twenty-server/src/engine/api/graphql/workspace-query-runner/factories/query-runner-args.factory.ts to process a single data object instead of an array for UpdateMany operations
  • Fixed incorrect type usage from UpdateOneResolverArgs.data to UpdateManyResolverArgs.data
  • Aligned UpdateMany data handling with UpdateOne resolver for consistency
  • Impacts integration tests, particularly all-people-resolvers.integration-spec.ts

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 108 to 110
data: await this.overrideDataByFieldMetadata(
(args as UpdateOneResolverArgs).data,
options,
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Incorrect type cast here - using UpdateOneResolverArgs.data when handling UpdateMany case. This could cause type safety issues.

Suggested change
data: await this.overrideDataByFieldMetadata(
(args as UpdateOneResolverArgs).data,
options,
(args as UpdateManyResolverArgs).data,
options,

},
),
) ?? [],
data: await this.overrideDataByFieldMetadata(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

unlike with CreateMany, data is not an array:

export interface CreateManyResolverArgs<
  Data extends Partial<ObjectRecord> = Partial<ObjectRecord>,
> {
  data: Data[];
  upsert?: boolean;
}

...

export interface UpdateManyResolverArgs<
  Data extends Partial<ObjectRecord> = Partial<ObjectRecord>,
  Filter = any,
> {
  filter: Filter;
  data: Data;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@eliasylonen FYI :)

@Weiko Weiko merged commit 645065a into main Feb 19, 2025
30 checks passed
@Weiko Weiko deleted the fix-query-runner-args branch February 19, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants