From 0980d6d9c829e47a5d1e905ee29de55c98053d1e Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Fri, 11 Oct 2024 17:04:12 +0200 Subject: [PATCH] Fix GraphQL Api Setters not being applied (#7602) While rebuilding the new GraphQLAPI (without pg_graphql), we forgot to include the FieldGetter logic. This logic will soon be moved at ORM level but we will need to keep it there for now The bug has many impacts such as the fileToken not being generated and preventing users from loading files --- .../graphql-query-runner.service.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/graphql-query-runner.service.ts b/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/graphql-query-runner.service.ts index d3d47daed171..7eb55d60ae95 100644 --- a/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/graphql-query-runner.service.ts +++ b/packages/twenty-server/src/engine/api/graphql/graphql-query-runner/graphql-query-runner.service.ts @@ -29,6 +29,7 @@ import { import { GraphqlQueryResolverFactory } from 'src/engine/api/graphql/graphql-query-runner/factories/graphql-query-resolver.factory'; import { ApiEventEmitterService } from 'src/engine/api/graphql/graphql-query-runner/services/api-event-emitter.service'; +import { QueryResultGettersFactory } from 'src/engine/api/graphql/workspace-query-runner/factories/query-result-getters/query-result-getters.factory'; import { QueryRunnerArgsFactory } from 'src/engine/api/graphql/workspace-query-runner/factories/query-runner-args.factory'; import { CallWebhookJobsJob, @@ -47,6 +48,7 @@ export class GraphqlQueryRunnerService { constructor( private readonly workspaceQueryHookService: WorkspaceQueryHookService, private readonly queryRunnerArgsFactory: QueryRunnerArgsFactory, + private readonly queryResultGettersFactory: QueryResultGettersFactory, @InjectMessageQueue(MessageQueue.webhookQueue) private readonly messageQueueService: MessageQueueService, private readonly graphqlQueryResolverFactory: GraphqlQueryResolverFactory, @@ -353,20 +355,28 @@ export class GraphqlQueryRunnerService { const results = await resolver.resolve(computedArgs as Input, options); + const resultWithGetters = await this.queryResultGettersFactory.create( + results, + objectMetadataItem, + authContext.workspace.id, + ); + await this.workspaceQueryHookService.executePostQueryHooks( authContext, objectMetadataItem.nameSingular, operationName, - Array.isArray(results) ? results : [results], + Array.isArray(resultWithGetters) + ? resultWithGetters + : [resultWithGetters], ); const jobOperation = this.operationNameToJobOperation(operationName); if (jobOperation) { - await this.triggerWebhooks(results, jobOperation, options); + await this.triggerWebhooks(resultWithGetters, jobOperation, options); } - return results; + return resultWithGetters; } private operationNameToJobOperation(