Skip to content

Instantly share code, notes, and snippets.

@socialwell-demos
Created June 8, 2022 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save socialwell-demos/84fee9c430c3741d5364044cab971cf7 to your computer and use it in GitHub Desktop.
Save socialwell-demos/84fee9c430c3741d5364044cab971cf7 to your computer and use it in GitHub Desktop.
Keystone List
import { list } from '@keystone-6/core';
import { select, relationship, text, timestamp } from '@keystone-6/core/fields';
export const lists = {
Post: list({
fields: {
title: text({ validation: { isRequired: true } }),
status: select({
type: 'enum',
options: [
{ label: 'Draft', value: 'draft' },
{ label: 'Published', value: 'published' },
],
}),
content: text(),
publishDate: timestamp(),
author: relationship({ ref: 'Author.posts', many: false }),
},
}),
Author: list({
fields: {
name: text({ validation: { isRequired: true } }),
email: text({ isIndexed: 'unique', validation: { isRequired: true } }),
posts: relationship({ ref: 'Post.author', many: true }),
},
}),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment