Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/keystone/lib/Keystone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = class Keystone {
addVersionToHttpHeaders: true,
access: true,
},
customTypeDefs = [],
}) {
this.defaultAccess = { list: true, field: true, custom: true, ...defaultAccess };
this.auth = {};
Expand All @@ -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();
Expand Down Expand Up @@ -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 }) {
Expand Down Expand Up @@ -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));
Expand Down
Loading