-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[Flexible-schema] Refactor gql query runner to emit api event before processing to gql types #8596
Conversation
…processing to gql types
{ | ||
filter: { id: { eq: args.id } }, | ||
}, | ||
return this.executeQuery<UpdateOneResolverArgs<Partial<T>>, T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this executeQuery layer
There was a problem hiding this 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 likeGraphqlQueryCreateManyResolverService
- Events now emit after record formatting but before GraphQL processing in all resolver services to prevent unwanted nesting/formatting
- Removed
removeGraphQLAndNestedProperties
method fromApiEventEmitterService
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
...es/twenty-server/src/engine/api/graphql/graphql-query-runner/graphql-query-runner.service.ts
Outdated
Show resolved
Hide resolved
...ine/api/graphql/graphql-query-runner/resolvers/graphql-query-create-many-resolver.service.ts
Outdated
Show resolved
Hide resolved
...ine/api/graphql/graphql-query-runner/resolvers/graphql-query-update-many-resolver.service.ts
Outdated
Show resolved
Hide resolved
const nonFormattedUpdatedObjectRecords = await queryBuilder | ||
.update(data) | ||
.where({ id: args.id }) | ||
.returning('*') | ||
.execute(); |
There was a problem hiding this comment.
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
...nty-server/src/engine/api/graphql/graphql-query-runner/services/api-event-emitter.service.ts
Show resolved
Hide resolved
…vent-emit-before-gql-processing
…vent-emit-before-gql-processing
}); | ||
} | ||
|
||
async; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whow!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops!
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