Skip to content

Commit

Permalink
[Flexible-schema] Refactor gql query runner to emit api event before …
Browse files Browse the repository at this point in the history
…processing to gql types (#8596)

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
  • Loading branch information
Weiko authored Nov 21, 2024
1 parent 8f5515c commit 1c04b2b
Show file tree
Hide file tree
Showing 46 changed files with 1,254 additions and 1,052 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export enum DatabaseEventAction {
UPDATED = 'updated',
DELETED = 'deleted',
DESTROYED = 'destroyed',
RESTORED = 'restored',
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Module } from '@nestjs/common';

import { GraphqlQueryResolverFactory } from 'src/engine/api/graphql/graphql-query-runner/factories/graphql-query-resolver.factory';
import { GraphqlQueryRunnerService } from 'src/engine/api/graphql/graphql-query-runner/graphql-query-runner.service';
import { GraphqlQueryCreateManyResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-create-many-resolver.service';
import { GraphqlQueryCreateOneResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-create-one-resolver.service';
import { GraphqlQueryDeleteManyResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-delete-many-resolver.service';
import { GraphqlQueryDeleteOneResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-delete-one-resolver.service';
import { GraphqlQueryDestroyManyResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-destroy-many-resolver.service';
import { GraphqlQueryDestroyOneResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-destroy-one-resolver.service';
import { GraphqlQueryFindDuplicatesResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-find-duplicates-resolver.service';
import { GraphqlQueryFindManyResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-find-many-resolver.service';
import { GraphqlQueryFindOneResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-find-one-resolver.service';
import { GraphqlQueryRestoreManyResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-restore-many-resolver.service';
import { GraphqlQueryRestoreOneResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-restore-one-resolver.service';
import { GraphqlQuerySearchResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-search-resolver.service';
import { GraphqlQueryUpdateManyResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-update-many-resolver.service';
import { GraphqlQueryUpdateOneResolverService } from 'src/engine/api/graphql/graphql-query-runner/resolvers/graphql-query-update-one-resolver.service';
Expand All @@ -18,11 +21,16 @@ import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-

const graphqlQueryResolvers = [
GraphqlQueryCreateManyResolverService,
GraphqlQueryCreateOneResolverService,
GraphqlQueryDeleteManyResolverService,
GraphqlQueryDeleteOneResolverService,
GraphqlQueryDestroyManyResolverService,
GraphqlQueryDestroyOneResolverService,
GraphqlQueryFindDuplicatesResolverService,
GraphqlQueryFindManyResolverService,
GraphqlQueryFindOneResolverService,
GraphqlQueryRestoreManyResolverService,
GraphqlQueryRestoreOneResolverService,
GraphqlQuerySearchResolverService,
GraphqlQueryUpdateManyResolverService,
GraphqlQueryUpdateOneResolverService,
Expand All @@ -34,12 +42,7 @@ const graphqlQueryResolvers = [
WorkspaceQueryRunnerModule,
FeatureFlagModule,
],
providers: [
GraphqlQueryRunnerService,
GraphqlQueryResolverFactory,
ApiEventEmitterService,
...graphqlQueryResolvers,
],
exports: [GraphqlQueryRunnerService],
providers: [ApiEventEmitterService, ...graphqlQueryResolvers],
exports: [...graphqlQueryResolvers],
})
export class GraphqlQueryRunnerModule {}
Loading

0 comments on commit 1c04b2b

Please sign in to comment.