Remove direct execution feature flag - WIP (#19254)
Bug fixes exposed by always-on direct execution
1. GraphQL spec compliance — data[field] = null on resolver error
direct-execution.service.ts — Changed from Promise.allSettled (which
lost the responseKey on rejection) to Promise.all with per-field
try/catch; errors now set data[responseKey] = null per spec
2. Empty object arguments skipped (extractArgumentsFromAst)
extract-arguments-from-ast.util.ts — Removed isEmptyObject check;
filter: {}, data: {} now correctly passed to resolvers instead of
silently dropped (which caused permissions to never be checked)
3. orderBy: {} factory default treated as "no ordering"
direct-execution.service.ts — Before calling the resolver, strips
orderBy: {} and orderByForRecords: {} (empty-object factory defaults
that mean "no ordering")
assert-find-many-args.util.ts / assert-group-by-args.util.ts — Accept {}
for orderBy without throwing
4. orderBy: { field: '...' } object auto-coerced to [{ field: '...' }]
array
direct-execution.service.ts — Applies GraphQL list coercion: a
non-array, non-empty orderBy object is wrapped in an array before
assertion and resolver call
5. totalCount and aggregate fields returned as strings from PostgreSQL
graphql-format-result-from-selected-fields.util.ts — Added
coerceAggregateValue that parses numeric strings to numbers for
totalCount, sum*, avg*, min*, max*, count*, percentageOf* fields
Test updates
nested-relation-queries.integration-spec.ts — Updated expected error
message from Yoga schema-validation message to direct execution resolver
message
~30 snapshot files — Updated to reflect direct execution's error
messages (different from Yoga schema-validation messages for input type
errors)
This commit is contained in:
+27
-18
@@ -25,7 +25,10 @@ import {
|
||||
CommonQueryArgs,
|
||||
CommonQueryNames,
|
||||
} from 'src/engine/api/common/types/common-query-args.type';
|
||||
import { CommonQueryResult } from 'src/engine/api/common/types/common-query-result.type';
|
||||
import {
|
||||
CommonQueryExecutionResult,
|
||||
CommonQueryResult,
|
||||
} from 'src/engine/api/common/types/common-query-result.type';
|
||||
import { CommonSelectedFieldsResult } from 'src/engine/api/common/types/common-selected-fields-result.type';
|
||||
import { OBJECTS_WITH_SETTINGS_PERMISSIONS_REQUIREMENTS } from 'src/engine/api/graphql/graphql-query-runner/constants/objects-with-settings-permissions-requirements';
|
||||
import { GraphqlQueryParser } from 'src/engine/api/graphql/graphql-query-runner/graphql-query-parsers/graphql-query.parser';
|
||||
@@ -98,7 +101,7 @@ export abstract class CommonBaseQueryRunnerService<
|
||||
public async execute(
|
||||
args: CommonInput<Args>,
|
||||
queryRunnerContext: CommonBaseQueryRunnerContext,
|
||||
): Promise<Output> {
|
||||
): Promise<CommonQueryExecutionResult<Output, Args>> {
|
||||
const {
|
||||
authContext,
|
||||
flatObjectMetadata,
|
||||
@@ -127,26 +130,32 @@ export abstract class CommonBaseQueryRunnerService<
|
||||
args.selectedFields,
|
||||
);
|
||||
|
||||
this.validateQueryComplexity(
|
||||
selectedFieldsResult,
|
||||
args,
|
||||
queryRunnerContext,
|
||||
);
|
||||
|
||||
const processedArgs = {
|
||||
...(await this.processArgs(args, queryRunnerContext, this.operationName)),
|
||||
selectedFieldsResult,
|
||||
} as CommonExtendedInput<Args>;
|
||||
|
||||
return this.globalWorkspaceOrmManager.executeInWorkspaceContext(
|
||||
async () =>
|
||||
this.executeQueryAndEnrichResults(
|
||||
processedArgs,
|
||||
queryRunnerContext,
|
||||
commonQueryParser,
|
||||
),
|
||||
authContext,
|
||||
this.validateQueryComplexity(
|
||||
selectedFieldsResult,
|
||||
processedArgs,
|
||||
queryRunnerContext,
|
||||
);
|
||||
|
||||
const results =
|
||||
await this.globalWorkspaceOrmManager.executeInWorkspaceContext(
|
||||
async () =>
|
||||
this.executeQueryAndEnrichResults(
|
||||
processedArgs,
|
||||
queryRunnerContext,
|
||||
commonQueryParser,
|
||||
),
|
||||
authContext,
|
||||
);
|
||||
|
||||
return {
|
||||
results,
|
||||
args: processedArgs,
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract run(
|
||||
@@ -174,7 +183,7 @@ export abstract class CommonBaseQueryRunnerService<
|
||||
|
||||
protected computeQueryComplexity(
|
||||
selectedFieldsResult: CommonSelectedFieldsResult,
|
||||
_args: CommonInput<Args>,
|
||||
_args: CommonExtendedInput<Args>,
|
||||
_queryRunnerContext: CommonBaseQueryRunnerContext,
|
||||
): number {
|
||||
const simpleFieldsComplexity = 1;
|
||||
@@ -387,7 +396,7 @@ export abstract class CommonBaseQueryRunnerService<
|
||||
|
||||
private validateQueryComplexity(
|
||||
selectedFieldsResult: CommonSelectedFieldsResult,
|
||||
args: CommonInput<Args>,
|
||||
args: CommonExtendedInput<Args>,
|
||||
queryRunnerContext: CommonBaseQueryRunnerContext,
|
||||
) {
|
||||
const maximumComplexity = this.twentyConfigService.get(
|
||||
|
||||
+1
-1
@@ -318,7 +318,7 @@ export class CommonFindManyQueryRunnerService extends CommonBaseQueryRunnerServi
|
||||
|
||||
protected override computeQueryComplexity(
|
||||
selectedFieldsResult: CommonSelectedFieldsResult,
|
||||
args: CommonInput<FindManyQueryArgs>,
|
||||
args: CommonExtendedInput<FindManyQueryArgs>,
|
||||
queryRunnerContext: CommonBaseQueryRunnerContext,
|
||||
): number {
|
||||
const baseComplexity = super.computeQueryComplexity(
|
||||
|
||||
Reference in New Issue
Block a user