From 9ed51792fb09c9d78a8ce00722faa91c88983d8b Mon Sep 17 00:00:00 2001 From: Sitnikov Ivan Date: Tue, 26 Aug 2025 10:38:59 +0500 Subject: [PATCH 1/2] chore(keystone): INFRA-1009 add ability to override custom typedefs --- packages/keystone/lib/Keystone/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/keystone/lib/Keystone/index.js b/packages/keystone/lib/Keystone/index.js index 5b63bf03c4..2f5de47f0d 100644 --- a/packages/keystone/lib/Keystone/index.js +++ b/packages/keystone/lib/Keystone/index.js @@ -44,6 +44,7 @@ module.exports = class Keystone { addVersionToHttpHeaders: true, access: true, }, + customTypeDefs = [], }) { this.defaultAccess = { list: true, field: true, custom: true, ...defaultAccess }; this.auth = {}; @@ -59,6 +60,7 @@ module.exports = class Keystone { this.eventHandlers = { onConnect }; this.registeredTypes = new Set(); this._schemaNames = schemaNames; + this._customTypeDefs = customTypeDefs this.appVersion = appVersion; this._listCRUDProvider = new ListCRUDProvider(); @@ -86,6 +88,10 @@ module.exports = class Keystone { if (this.queryLimits.maxTotalResults < 1) { throw new Error("queryLimits.maxTotalResults can't be < 1"); } + + if (!Array.isArray(this._customTypeDefs)) { + throw new Error("customTypeDefs should be Array. For example, ['scalar YourOwnScalarType']") + } } _getAccessControlContext({ schemaName, authentication, skipAccessControl }) { @@ -543,6 +549,7 @@ module.exports = class Keystone { mutations.length > 0 && `type Mutation { ${mutations.join('\n')} }`, subscriptions.length > 0 && `type Subscription { ${subscriptions.join('\n')} }`, 'scalar Upload', + ...unique(this._customTypeDefs), ] .filter(s => s) .map(s => gql(s)); From b0bda6bb24516a90f35fa4abdb5c71f24c4a7c38 Mon Sep 17 00:00:00 2001 From: Sitnikov Ivan Date: Tue, 26 Aug 2025 10:55:35 +0500 Subject: [PATCH 2/2] chore(keystone): INFRA-1009 linter issues --- packages/keystone/lib/Keystone/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/keystone/lib/Keystone/index.js b/packages/keystone/lib/Keystone/index.js index 2f5de47f0d..484652865b 100644 --- a/packages/keystone/lib/Keystone/index.js +++ b/packages/keystone/lib/Keystone/index.js @@ -60,7 +60,7 @@ module.exports = class Keystone { this.eventHandlers = { onConnect }; this.registeredTypes = new Set(); this._schemaNames = schemaNames; - this._customTypeDefs = customTypeDefs + this._customTypeDefs = customTypeDefs; this.appVersion = appVersion; this._listCRUDProvider = new ListCRUDProvider(); @@ -90,7 +90,7 @@ module.exports = class Keystone { } if (!Array.isArray(this._customTypeDefs)) { - throw new Error("customTypeDefs should be Array. For example, ['scalar YourOwnScalarType']") + throw new Error("customTypeDefs should be Array. For example, ['scalar YourOwnScalarType']"); } }