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

[Flexible-schema] Refactor gql query runner to emit api event before processing to gql types #8596

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Nov 19, 2024

Fixes #8300

Context

API events were created too late and were already formatted as Gql responses (including nesting with edges/node/type + formatting that should not exist in an event payload). This PR moves the emit logic to the resolver where we actually do the DB query
Note: Also added RESTORED events

{
filter: { id: { eq: args.id } },
},
return this.executeQuery<UpdateOneResolverArgs<Partial<T>>, T>(
Copy link
Member

Choose a reason for hiding this comment

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

remove this executeQuery layer

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 PR moves API event emission logic from GraphqlQueryRunnerService to individual resolver services, ensuring events contain raw database records before GraphQL processing occurs.

  • Removed event emission from GraphqlQueryRunnerService and distributed to individual resolver services like GraphqlQueryCreateManyResolverService
  • Events now emit after record formatting but before GraphQL processing in all resolver services to prevent unwanted nesting/formatting
  • Removed removeGraphQLAndNestedProperties method from ApiEventEmitterService to pass raw records directly
  • Added consistent fetching of existing records before updates to properly track changes
  • Standardized event emission timing across all resolvers (create/update/destroy) to occur post-formatting but pre-GraphQL processing

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

Comment on lines 84 to 88
const nonFormattedUpdatedObjectRecords = await queryBuilder
.update(data)
.where({ id: args.id })
.returning('*')
.execute();
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Transaction needed to ensure atomicity between read and update operations

});
}

async;
Copy link
Member

Choose a reason for hiding this comment

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

whow!

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops!

@charlesBochet charlesBochet merged commit 1c04b2b into main Nov 21, 2024
19 checks passed
@charlesBochet charlesBochet deleted the c--refactor-graphql-query-runner--move-api-event-emit-before-gql-processing branch November 21, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants