Skip to Page NavigationSkip to Page NavigationSkip to Content
Keystone 6 is in Community Preview! For Keystone 5 docs visit v5.keystonejs.com

Release: 15th November 2021

Expanded unique filters, customisable table and column names support and a new example featuring Nexus as we continue to finalise our GA release. ๐Ÿชข

"@keystone-next/auth": "36.0.0",
"@keystone-next/cloudinary": "11.0.0",
"@keystone-next/fields-document": "13.0.0",
"@keystone-next/keystone": "28.0.0",
"@keystone-next/session-store-redis": "8.0.0",

Like this release? Give us a star on GitHub!

Expanded Unique Filters ๐Ÿ”Ž

select, timestamp, float and decimal fields with isIndexed: 'unique' now have unique filters via ListWhereUniqueInput which text, integer and the id field already support.

For example, if you added isIndexed: 'unique' to a select field in a theoretical Settings list, you can now run the following query:

query {
  setting ( where: { provider: "github" } ) {
		id
		token
  }
}

This is instead of running a settings query where you would have received a list back, and have had to check for results and get the first element:

query {
  settings ( where: { provider: { equals: "github" } } ) {
		id
		token
  }
}

Customisable Table and Column Names ๐Ÿ“‡

You may now use different table and column names to those automatically chosen by Keystone for your list and field keys. This is powered by Prisma's @map and @@map attributes. You can read more about this concept in Prisma's documentation.

This is useful if you do not want to modify your existing database (such as a read-only database) and use it with Keystone.

For example if you wanted to refer to a table named stories but you refer to it in Keystone as Posts provide config.db.map to a list or field key such as:

Post: list({
  db: {
    map: 'stories',
  },
  fields: {
    ...
  }
})

Nexus Example ๐Ÿชข

We've got a new example using Nexus, a declarative, code-first and strongly typed GraphQL schema construction for TypeScript & JavaScript.

Using Nexus you can extend the GraphQL API provided by Keystone with custom queries and mutations.

In the example below we expose a mutation called nexusPosts which pulls out items from our Posts list that have been published within the past 7 days (by default), with an optional author filter.

export const PostQuery = extendType({
	type: 'Query',
	definition(t) {
		t.field('nexusPosts', {
			type: nonNull(list('NexusPost')),
			args: {
				authorId: stringArg(),
				days: nonNull(intArg({ default: 7 })),
			},
			async resolve(root, { authorId, days }, context) {
				const cutoff = new Date(
					new Date().setUTCDate(new Date().getUTCDate() - days)
				).toISOString();

				return await context.prisma.post.findMany({
					where: {
						...(authorId ? { author: { id: authorId } } : null),
						publishDate: { gt: cutoff },
					},
				});
			},
		});
	},
});

Check out the example in Keystone's examples directory.

Miscellaneous Fixes โš™๏ธ

  • The format of the date shown in the DatePicker now uses the user's locale.
  • When the sessionData option is invalid, the error will now be thrown on startup instead of silently ignored.

Complete Changelog ๐Ÿ“œ

You can also view the verbose changelog in the related PR (https://github.com/keystonejs/keystone/pull/6914) for this release.