Skip to content

Instantly share code, notes, and snippets.

@tgriesser
Last active February 1, 2019 13:47
Show Gist options
  • Save tgriesser/9e66593e980ee17ad8f4d304d9cfe792 to your computer and use it in GitHub Desktop.
Save tgriesser/9e66593e980ee17ad8f4d304d9cfe792 to your computer and use it in GitHub Desktop.
function commonPostFields(t) {
t.string('title')
t.string('body')
t.list.field('tags', { type: TagEnum })
t.field('meta', { type: "PostMetadata" })
}
export const Post = objectType({
name: "Post",
definition(t) {
t.implements('Node')
commonPostFields(t)
}
})
export const CreatePostInput = inputObjectType({
name: "CreatePostInput",
definition(t) {
commonPostFields(t)
}
})
export const UpdatePostInput = inputObjectType({
name: "UpdatePostInput",
definition(t) {
t.id('id', { required: true })
commonPostFields(t)
}
})
export const PostTagEnum = enumType({
name: "PostTags",
members: ["DRAFT", "PUBLISHED"]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment