From fb0a08306d08940270c094160dfbf1b6cfe4d842 Mon Sep 17 00:00:00 2001 From: martmull Date: Thu, 25 Jul 2024 08:11:36 +0200 Subject: [PATCH 1/2] Set default depth to 1 --- .../utils/map-field-metadata-to-graphql-query.utils.ts | 2 +- .../open-api/utils/__tests__/parameters.utils.spec.ts | 1 + .../src/engine/core-modules/open-api/utils/parameters.utils.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/twenty-server/src/engine/api/rest/core/query-builder/utils/map-field-metadata-to-graphql-query.utils.ts b/packages/twenty-server/src/engine/api/rest/core/query-builder/utils/map-field-metadata-to-graphql-query.utils.ts index a34cc2123f36..8b22e2f7101b 100644 --- a/packages/twenty-server/src/engine/api/rest/core/query-builder/utils/map-field-metadata-to-graphql-query.utils.ts +++ b/packages/twenty-server/src/engine/api/rest/core/query-builder/utils/map-field-metadata-to-graphql-query.utils.ts @@ -1,7 +1,7 @@ import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { RelationMetadataType } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity'; -const DEFAULT_DEPTH_VALUE = 2; +const DEFAULT_DEPTH_VALUE = 1; // TODO: Should be properly type and based on composite type definitions export const mapFieldMetadataToGraphqlQuery = ( diff --git a/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/parameters.utils.spec.ts b/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/parameters.utils.spec.ts index f91da6a750e6..a4f6b6fcc00c 100644 --- a/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/parameters.utils.spec.ts +++ b/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/parameters.utils.spec.ts @@ -69,6 +69,7 @@ describe('computeParameters', () => { schema: { type: 'integer', enum: [0, 1, 2], + default: 1, }, }); }); diff --git a/packages/twenty-server/src/engine/core-modules/open-api/utils/parameters.utils.ts b/packages/twenty-server/src/engine/core-modules/open-api/utils/parameters.utils.ts index 56034403a912..954e567e85a6 100644 --- a/packages/twenty-server/src/engine/core-modules/open-api/utils/parameters.utils.ts +++ b/packages/twenty-server/src/engine/core-modules/open-api/utils/parameters.utils.ts @@ -60,6 +60,7 @@ export const computeDepthParameters = (): OpenAPIV3_1.ParameterObject => { schema: { type: 'integer', enum: [0, 1, 2], + default: 1, }, }; }; From 3bab4d86d2bdf3ce325031b00a7ffe5ee0cb39f4 Mon Sep 17 00:00:00 2001 From: martmull Date: Thu, 25 Jul 2024 08:29:06 +0200 Subject: [PATCH 2/2] Improve timeout message --- .../workspace-query-runner/workspace-query-runner.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts index 1ab7764f5549..57f102905508 100644 --- a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts +++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts @@ -643,7 +643,9 @@ export class WorkspaceQueryRunnerService { ); } catch (error) { if (isQueryTimeoutError(error)) { - throw new RequestTimeoutException(error.message); + throw new RequestTimeoutException( + 'The SQL request took too long to process, resulting in a query read timeout. To resolve this issue, consider modifying your query by reducing the depth of relationships or limiting the number of records being fetched.', + ); } throw error;