Skip to content

Commit

Permalink
Add Cloudinary example (#8816)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens authored Sep 19, 2023
1 parent b88944b commit f6c8f9f
Show file tree
Hide file tree
Showing 53 changed files with 445 additions and 414 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.next
.keystone
dist/
Expand Down
3 changes: 1 addition & 2 deletions examples/assets-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
"devDependencies": {
"prisma": "^4.16.2",
"typescript": "~5.0.0"
},
"repository": "https://github.com/keystonejs/keystone/tree/main/examples/assets-local"
}
}
129 changes: 3 additions & 126 deletions examples/assets-local/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@
type Post {
id: ID!
title: String
status: PostStatusType
content: String
publishDate: DateTime
author: Author
hero: ImageFieldOutput
banner: ImageFieldOutput
attachment: FileFieldOutput
}

enum PostStatusType {
draft
published
}

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

type ImageFieldOutput {
id: ID!
filesize: Int!
Expand Down Expand Up @@ -51,10 +41,7 @@ input PostWhereInput {
NOT: [PostWhereInput!]
id: IDFilter
title: StringFilter
status: PostStatusTypeNullableFilter
content: StringFilter
publishDate: DateTimeNullableFilter
author: AuthorWhereInput
}

input IDFilter {
Expand Down Expand Up @@ -96,30 +83,10 @@ input NestedStringFilter {
not: NestedStringFilter
}

input PostStatusTypeNullableFilter {
equals: PostStatusType
in: [PostStatusType!]
notIn: [PostStatusType!]
not: PostStatusTypeNullableFilter
}

input DateTimeNullableFilter {
equals: DateTime
in: [DateTime!]
notIn: [DateTime!]
lt: DateTime
lte: DateTime
gt: DateTime
gte: DateTime
not: DateTimeNullableFilter
}

input PostOrderByInput {
id: OrderDirection
title: OrderDirection
status: OrderDirection
content: OrderDirection
publishDate: OrderDirection
}

enum OrderDirection {
Expand All @@ -129,20 +96,11 @@ enum OrderDirection {

input PostUpdateInput {
title: String
status: PostStatusType
content: String
publishDate: DateTime
author: AuthorRelateToOneForUpdateInput
hero: ImageFieldInput
banner: ImageFieldInput
attachment: FileFieldInput
}

input AuthorRelateToOneForUpdateInput {
create: AuthorCreateInput
connect: AuthorWhereUniqueInput
disconnect: Boolean
}

input ImageFieldInput {
upload: Upload!
}
Expand All @@ -161,83 +119,11 @@ input PostUpdateArgs {

input PostCreateInput {
title: String
status: PostStatusType
content: String
publishDate: DateTime
author: AuthorRelateToOneForCreateInput
hero: ImageFieldInput
banner: ImageFieldInput
attachment: FileFieldInput
}

input AuthorRelateToOneForCreateInput {
create: AuthorCreateInput
connect: AuthorWhereUniqueInput
}

type Author {
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 {
id: ID
email: String
}

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

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

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

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

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

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

input AuthorCreateInput {
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).
"""
Expand All @@ -250,21 +136,12 @@ type Mutation {
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]
}

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
keystone: KeystoneMeta!
}

Expand Down
29 changes: 8 additions & 21 deletions examples/assets-local/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,14 @@ generator client {
}

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")
hero_filesize Int?
hero_extension String?
hero_width Int?
hero_height Int?
hero_id String?
id String @id @default(cuid())
title String @default("")
content String @default("")
banner_filesize Int?
banner_extension String?
banner_width Int?
banner_height Int?
banner_id String?
attachment_filesize Int?
attachment_filename String?
@@index([authorId])
}

model Author {
id String @id @default(cuid())
name String @default("")
email String @unique @default("")
posts Post[] @relation("Post_author")
}
21 changes: 2 additions & 19 deletions examples/assets-local/schema.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
import { list } from '@keystone-6/core';
import { allowAll } from '@keystone-6/core/access';
import { select, relationship, text, timestamp, image, file } from '@keystone-6/core/fields';
import { text, image, file } from '@keystone-6/core/fields';

export const lists = {
Post: list({
access: allowAll,
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 }),
hero: image({ storage: 'my_images' }),
banner: image({ storage: 'my_images' }),
attachment: file({ storage: 'my_files' }),
},
}),
Author: list({
access: allowAll,
fields: {
name: text({ validation: { isRequired: true } }),
email: text({ isIndexed: 'unique', validation: { isRequired: true } }),
posts: relationship({ ref: 'Post.author', many: true }),
},
}),
};
8 changes: 4 additions & 4 deletions examples/assets-s3/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
S3_BUCKET_NAME=S3_BUCKET_NAME
S3_ACCESS_KEY_ID=S3_ACCESS_KEY_ID
S3_SECRET_ACCESS_KEY=S3_SECRET_ACCESS_KEY
S3_REGION=S3_REGION
S3_BUCKET_NAME=
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=
S3_REGION=
1 change: 0 additions & 1 deletion examples/assets-s3/.gitignore

This file was deleted.

4 changes: 1 addition & 3 deletions examples/assets-s3/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'dotenv/config';
import { config } from '@keystone-6/core';
import dotenv from 'dotenv';
import { fixPrismaPath } from '../example-utils';
import { lists } from './schema';

dotenv.config();

const {
S3_BUCKET_NAME: bucketName = 'keystone-test',
S3_REGION: region = 'ap-southeast-2',
Expand Down
3 changes: 1 addition & 2 deletions examples/assets-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
"devDependencies": {
"prisma": "^4.16.2",
"typescript": "~5.0.0"
},
"repository": "https://github.com/keystonejs/keystone/tree/main/examples/assets-s3"
}
}
Loading

0 comments on commit f6c8f9f

Please sign in to comment.