Skip to content

Commit

Permalink
Fix GraphQL Api Setters not being applied (#7602)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
charlesBochet authored Oct 11, 2024
1 parent 0cb9853 commit 0980d6d
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 0980d6d

Please sign in to comment.