[Flexible-schema] Add findOne and fix findMany pagination + soft-delete for graphql-query-runner (#6978)
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
import {
|
||||
GraphqlQueryRunnerException,
|
||||
GraphqlQueryRunnerExceptionCode,
|
||||
} from 'src/engine/api/graphql/graphql-query-runner/errors/graphql-query-runner.exception';
|
||||
import {
|
||||
WorkspaceQueryRunnerException,
|
||||
WorkspaceQueryRunnerExceptionCode,
|
||||
@ -32,5 +36,23 @@ export const workspaceQueryRunnerGraphqlApiExceptionHandler = (
|
||||
}
|
||||
}
|
||||
|
||||
if (error instanceof GraphqlQueryRunnerException) {
|
||||
switch (error.code) {
|
||||
case GraphqlQueryRunnerExceptionCode.INVALID_QUERY_INPUT:
|
||||
case GraphqlQueryRunnerExceptionCode.OBJECT_METADATA_NOT_FOUND:
|
||||
case GraphqlQueryRunnerExceptionCode.MAX_DEPTH_REACHED:
|
||||
case GraphqlQueryRunnerExceptionCode.INVALID_CURSOR:
|
||||
case GraphqlQueryRunnerExceptionCode.INVALID_DIRECTION:
|
||||
case GraphqlQueryRunnerExceptionCode.UNSUPPORTED_OPERATOR:
|
||||
case GraphqlQueryRunnerExceptionCode.ARGS_CONFLICT:
|
||||
case GraphqlQueryRunnerExceptionCode.FIELD_NOT_FOUND:
|
||||
throw new UserInputError(error.message);
|
||||
case GraphqlQueryRunnerExceptionCode.RECORD_NOT_FOUND:
|
||||
throw new NotFoundError(error.message);
|
||||
default:
|
||||
throw new InternalServerError(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
throw error;
|
||||
};
|
||||
|
||||
@ -122,10 +122,7 @@ export class WorkspaceQueryRunnerService {
|
||||
)) as FindManyResolverArgs<Filter, OrderBy>;
|
||||
|
||||
if (isQueryRunnerTwentyORMEnabled) {
|
||||
return this.graphqlQueryRunnerService.findManyWithTwentyOrm(
|
||||
computedArgs,
|
||||
options,
|
||||
);
|
||||
return this.graphqlQueryRunnerService.findMany(computedArgs, options);
|
||||
}
|
||||
|
||||
const query = await this.workspaceQueryBuilderFactory.findMany(
|
||||
@ -169,6 +166,12 @@ export class WorkspaceQueryRunnerService {
|
||||
}
|
||||
const { authContext, objectMetadataItem } = options;
|
||||
|
||||
const isQueryRunnerTwentyORMEnabled =
|
||||
await this.featureFlagService.isFeatureEnabled(
|
||||
FeatureFlagKey.IsQueryRunnerTwentyORMEnabled,
|
||||
authContext.workspace.id,
|
||||
);
|
||||
|
||||
const hookedArgs =
|
||||
await this.workspaceQueryHookService.executePreQueryHooks(
|
||||
authContext,
|
||||
@ -183,6 +186,10 @@ export class WorkspaceQueryRunnerService {
|
||||
ResolverArgsType.FindOne,
|
||||
)) as FindOneResolverArgs<Filter>;
|
||||
|
||||
if (isQueryRunnerTwentyORMEnabled) {
|
||||
return this.graphqlQueryRunnerService.findOne(computedArgs, options);
|
||||
}
|
||||
|
||||
const query = await this.workspaceQueryBuilderFactory.findOne(
|
||||
computedArgs,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user