Skip to content

Commit

Permalink
update usecase-blog with indepth commentary and a tags list (#8477)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Cousens <[email protected]>
  • Loading branch information
dcousens and dcousens authored Apr 12, 2023
1 parent 4ee09ea commit f501526
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 107 deletions.
1 change: 1 addition & 0 deletions examples/usecase-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@keystone-6/core": "^5.0.0",
"@keystone-6/fields-document": "^7.0.0",
"@prisma/client": "^4.12.0"
},
"devDependencies": {
Expand Down
224 changes: 144 additions & 80 deletions examples/usecase-blog/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# This file is automatically generated by Keystone, do not modify it manually.
# Modify your Keystone config when you want to change this.

type Post {
type Author {
id: ID!
title: String
status: PostStatusType
content: String
publishDate: DateTime
author: Author
name: String
email: String
password: PasswordState
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
postsCount(where: PostWhereInput! = {}): Int
createdAt: DateTime
}

enum PostStatusType {
draft
published
type PasswordState {
isSet: Boolean!
}

scalar DateTime @specifiedBy(url: "https://datatracker.ietf.org/doc/html/rfc3339#section-5.6")

input PostWhereUniqueInput {
input AuthorWhereUniqueInput {
id: ID
email: String
}

input PostWhereInput {
AND: [PostWhereInput!]
OR: [PostWhereInput!]
NOT: [PostWhereInput!]
input AuthorWhereInput {
AND: [AuthorWhereInput!]
OR: [AuthorWhereInput!]
NOT: [AuthorWhereInput!]
id: IDFilter
title: StringFilter
status: PostStatusTypeNullableFilter
content: StringFilter
publishDate: DateTimeNullableFilter
author: AuthorWhereInput
name: StringFilter
email: StringFilter
posts: PostManyRelationFilter
createdAt: DateTimeNullableFilter
}

input IDFilter {
Expand Down Expand Up @@ -72,11 +72,10 @@ input NestedStringFilter {
not: NestedStringFilter
}

input PostStatusTypeNullableFilter {
equals: PostStatusType
in: [PostStatusType!]
notIn: [PostStatusType!]
not: PostStatusTypeNullableFilter
input PostManyRelationFilter {
every: PostWhereInput
some: PostWhereInput
none: PostWhereInput
}

input DateTimeNullableFilter {
Expand All @@ -90,25 +89,94 @@ input DateTimeNullableFilter {
not: DateTimeNullableFilter
}

input PostOrderByInput {
input AuthorOrderByInput {
id: OrderDirection
title: OrderDirection
status: OrderDirection
content: OrderDirection
publishDate: OrderDirection
name: OrderDirection
email: OrderDirection
createdAt: OrderDirection
}

enum OrderDirection {
asc
desc
}

input AuthorUpdateInput {
name: String
email: String
password: String
posts: PostRelateToManyForUpdateInput
createdAt: DateTime
}

input PostRelateToManyForUpdateInput {
disconnect: [PostWhereUniqueInput!]
set: [PostWhereUniqueInput!]
create: [PostCreateInput!]
connect: [PostWhereUniqueInput!]
}

input AuthorUpdateArgs {
where: AuthorWhereUniqueInput!
data: AuthorUpdateInput!
}

input AuthorCreateInput {
name: String
email: String
password: String
posts: PostRelateToManyForCreateInput
createdAt: DateTime
}

input PostRelateToManyForCreateInput {
create: [PostCreateInput!]
connect: [PostWhereUniqueInput!]
}

type Post {
id: ID!
title: String
content: Post_content_Document
author: Author
tags(where: TagWhereInput! = {}, orderBy: [TagOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TagWhereUniqueInput): [Tag!]
tagsCount(where: TagWhereInput! = {}): Int
}

type Post_content_Document {
document(hydrateRelationships: Boolean! = false): JSON!
}

input PostWhereUniqueInput {
id: ID
}

input PostWhereInput {
AND: [PostWhereInput!]
OR: [PostWhereInput!]
NOT: [PostWhereInput!]
id: IDFilter
title: StringFilter
author: AuthorWhereInput
tags: TagManyRelationFilter
}

input TagManyRelationFilter {
every: TagWhereInput
some: TagWhereInput
none: TagWhereInput
}

input PostOrderByInput {
id: OrderDirection
title: OrderDirection
}

input PostUpdateInput {
title: String
status: PostStatusType
content: String
publishDate: DateTime
content: JSON
author: AuthorRelateToOneForUpdateInput
tags: TagRelateToManyForUpdateInput
}

input AuthorRelateToOneForUpdateInput {
Expand All @@ -117,115 +185,111 @@ input AuthorRelateToOneForUpdateInput {
disconnect: Boolean
}

input TagRelateToManyForUpdateInput {
disconnect: [TagWhereUniqueInput!]
set: [TagWhereUniqueInput!]
create: [TagCreateInput!]
connect: [TagWhereUniqueInput!]
}

input PostUpdateArgs {
where: PostWhereUniqueInput!
data: PostUpdateInput!
}

input PostCreateInput {
title: String
status: PostStatusType
content: String
publishDate: DateTime
content: JSON
author: AuthorRelateToOneForCreateInput
tags: TagRelateToManyForCreateInput
}

input AuthorRelateToOneForCreateInput {
create: AuthorCreateInput
connect: AuthorWhereUniqueInput
}

type Author {
input TagRelateToManyForCreateInput {
create: [TagCreateInput!]
connect: [TagWhereUniqueInput!]
}

type Tag {
id: ID!
name: String
email: String
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
postsCount(where: PostWhereInput! = {}): Int
}

input AuthorWhereUniqueInput {
input TagWhereUniqueInput {
id: ID
email: String
}

input AuthorWhereInput {
AND: [AuthorWhereInput!]
OR: [AuthorWhereInput!]
NOT: [AuthorWhereInput!]
input TagWhereInput {
AND: [TagWhereInput!]
OR: [TagWhereInput!]
NOT: [TagWhereInput!]
id: IDFilter
name: StringFilter
email: StringFilter
posts: PostManyRelationFilter
}

input PostManyRelationFilter {
every: PostWhereInput
some: PostWhereInput
none: PostWhereInput
}

input AuthorOrderByInput {
input TagOrderByInput {
id: OrderDirection
name: OrderDirection
email: OrderDirection
}

input AuthorUpdateInput {
input TagUpdateInput {
name: String
email: String
posts: PostRelateToManyForUpdateInput
}

input PostRelateToManyForUpdateInput {
disconnect: [PostWhereUniqueInput!]
set: [PostWhereUniqueInput!]
create: [PostCreateInput!]
connect: [PostWhereUniqueInput!]
input TagUpdateArgs {
where: TagWhereUniqueInput!
data: TagUpdateInput!
}

input AuthorUpdateArgs {
where: AuthorWhereUniqueInput!
data: AuthorUpdateInput!
}

input AuthorCreateInput {
input TagCreateInput {
name: String
email: String
posts: PostRelateToManyForCreateInput
}

input PostRelateToManyForCreateInput {
create: [PostCreateInput!]
connect: [PostWhereUniqueInput!]
}

"""
The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
"""
scalar JSON @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")

type Mutation {
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post
updatePosts(data: [PostUpdateArgs!]!): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createAuthor(data: AuthorCreateInput!): Author
createAuthors(data: [AuthorCreateInput!]!): [Author]
updateAuthor(where: AuthorWhereUniqueInput!, data: AuthorUpdateInput!): Author
updateAuthors(data: [AuthorUpdateArgs!]!): [Author]
deleteAuthor(where: AuthorWhereUniqueInput!): Author
deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author]
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post
updatePosts(data: [PostUpdateArgs!]!): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createTag(data: TagCreateInput!): Tag
createTags(data: [TagCreateInput!]!): [Tag]
updateTag(where: TagWhereUniqueInput!, data: TagUpdateInput!): Tag
updateTags(data: [TagUpdateArgs!]!): [Tag]
deleteTag(where: TagWhereUniqueInput!): Tag
deleteTags(where: [TagWhereUniqueInput!]!): [Tag]
}

type Query {
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
post(where: PostWhereUniqueInput!): Post
postsCount(where: PostWhereInput! = {}): Int
authors(where: AuthorWhereInput! = {}, orderBy: [AuthorOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: AuthorWhereUniqueInput): [Author!]
author(where: AuthorWhereUniqueInput!): Author
authorsCount(where: AuthorWhereInput! = {}): Int
posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!]
post(where: PostWhereUniqueInput!): Post
postsCount(where: PostWhereInput! = {}): Int
tags(where: TagWhereInput! = {}, orderBy: [TagOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TagWhereUniqueInput): [Tag!]
tag(where: TagWhereUniqueInput!): Tag
tagsCount(where: TagWhereInput! = {}): Int
keystone: KeystoneMeta!
}

Expand Down
27 changes: 17 additions & 10 deletions examples/usecase-blog/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,28 @@ generator client {
output = "node_modules/.myprisma/client"
}

model Author {
id String @id @default(cuid())
name String @default("")
email String @unique @default("")
password String
posts Post[] @relation("Post_author")
createdAt DateTime? @default(now())
}

model Post {
id String @id @default(cuid())
title String @default("")
status String?
content String @default("")
publishDate DateTime?
author Author? @relation("Post_author", fields: [authorId], references: [id])
authorId String? @map("author")
id String @id @default(cuid())
title String @default("")
content String @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
author Author? @relation("Post_author", fields: [authorId], references: [id])
authorId String? @map("author")
tags Tag[] @relation("Post_tags")
@@index([authorId])
}

model Author {
model Tag {
id String @id @default(cuid())
name String @default("")
email String @unique @default("")
posts Post[] @relation("Post_author")
posts Post[] @relation("Post_tags")
}
Loading

0 comments on commit f501526

Please sign in to comment.