Skip to content

Commit

Permalink
Create GraphQL API updates (#6208)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Jul 28, 2021
1 parent e23f78c commit 092df66
Show file tree
Hide file tree
Showing 66 changed files with 376 additions and 718 deletions.
8 changes: 8 additions & 0 deletions .changeset/dull-humans-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@keystone-next/keystone': major
'@keystone-next/types': major
---

The create one mutation now requires a non-null `data` argument and the create many mutation accepts a list of `ItemCreateInput` directly instead of being nested inside of an object with the `ItemCreateInput` in a `data` field.

If you have a list called `Item`, `createItem` now looks like `createItem(data: ItemCreateInput!): Item` and `createItems` now looks like `createItems(data: [ItemCreateInput!]!): [Item]`.
16 changes: 4 additions & 12 deletions examples-staging/assets-cloud/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ input PostCreateInput {
attachment: FileFieldInput
}

input PostsCreateInput {
data: PostCreateInput
}

type Author {
id: ID!
name: String
Expand Down Expand Up @@ -238,10 +234,6 @@ input AuthorCreateInput {
posts: PostRelateToManyInput
}

input AuthorsCreateInput {
data: AuthorCreateInput
}

"""
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 @@ -251,14 +243,14 @@ scalar JSON
)

type Mutation {
createPost(data: PostCreateInput): Post
createPosts(data: [PostsCreateInput]): [Post]
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createAuthor(data: AuthorCreateInput): Author
createAuthors(data: [AuthorsCreateInput]): [Author]
createAuthor(data: AuthorCreateInput!): Author
createAuthors(data: [AuthorCreateInput!]!): [Author]
updateAuthor(id: ID!, data: AuthorUpdateInput): Author
updateAuthors(data: [AuthorUpdateArgs]): [Author]
deleteAuthor(where: AuthorWhereUniqueInput!): Author
Expand Down
16 changes: 4 additions & 12 deletions examples-staging/assets-local/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ input PostCreateInput {
hero: ImageFieldInput
}

input PostsCreateInput {
data: PostCreateInput
}

type Author {
id: ID!
name: String
Expand Down Expand Up @@ -216,10 +212,6 @@ input AuthorCreateInput {
posts: PostRelateToManyInput
}

input AuthorsCreateInput {
data: AuthorCreateInput
}

"""
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 @@ -229,14 +221,14 @@ scalar JSON
)

type Mutation {
createPost(data: PostCreateInput): Post
createPosts(data: [PostsCreateInput]): [Post]
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createAuthor(data: AuthorCreateInput): Author
createAuthors(data: [AuthorsCreateInput]): [Author]
createAuthor(data: AuthorCreateInput!): Author
createAuthors(data: [AuthorCreateInput!]!): [Author]
updateAuthor(id: ID!, data: AuthorUpdateInput): Author
updateAuthors(data: [AuthorUpdateArgs]): [Author]
deleteAuthor(where: AuthorWhereUniqueInput!): Author
Expand Down
8 changes: 2 additions & 6 deletions examples-staging/auth/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ input UserCreateInput {
isAdmin: Boolean
}

input UsersCreateInput {
data: UserCreateInput
}

"""
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 @@ -87,8 +83,8 @@ scalar JSON
)

type Mutation {
createUser(data: UserCreateInput): User
createUsers(data: [UsersCreateInput]): [User]
createUser(data: UserCreateInput!): User
createUsers(data: [UserCreateInput!]!): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(where: UserWhereUniqueInput!): User
Expand Down
24 changes: 6 additions & 18 deletions examples-staging/basic/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ input UserCreateInput {
posts: PostRelateToManyInput
}

input UsersCreateInput {
data: UserCreateInput
}

type PhoneNumber {
id: ID!
label: String
Expand Down Expand Up @@ -256,10 +252,6 @@ input PhoneNumberCreateInput {
value: String
}

input PhoneNumbersCreateInput {
data: PhoneNumberCreateInput
}

type Post {
id: ID!
title: String
Expand Down Expand Up @@ -338,10 +330,6 @@ input PostCreateInput {
author: UserRelateToOneInput
}

input PostsCreateInput {
data: PostCreateInput
}

"""
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 @@ -351,20 +339,20 @@ scalar JSON
)

type Mutation {
createUser(data: UserCreateInput): User
createUsers(data: [UsersCreateInput]): [User]
createUser(data: UserCreateInput!): User
createUsers(data: [UserCreateInput!]!): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
createPhoneNumber(data: PhoneNumberCreateInput): PhoneNumber
createPhoneNumbers(data: [PhoneNumbersCreateInput]): [PhoneNumber]
createPhoneNumber(data: PhoneNumberCreateInput!): PhoneNumber
createPhoneNumbers(data: [PhoneNumberCreateInput!]!): [PhoneNumber]
updatePhoneNumber(id: ID!, data: PhoneNumberUpdateInput): PhoneNumber
updatePhoneNumbers(data: [PhoneNumberUpdateArgs]): [PhoneNumber]
deletePhoneNumber(where: PhoneNumberWhereUniqueInput!): PhoneNumber
deletePhoneNumbers(where: [PhoneNumberWhereUniqueInput!]!): [PhoneNumber]
createPost(data: PostCreateInput): Post
createPosts(data: [PostsCreateInput]): [Post]
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
Expand Down
2 changes: 1 addition & 1 deletion examples-staging/basic/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const extendGraphqlSchema = graphQLSchemaExtension({
createRandomPosts(root, args, context) {
// TODO: add a way to verify access control here, e.g
// await context.verifyAccessControl(userIsAdmin);
const data = Array.from({ length: 238 }).map((x, i) => ({ data: { title: `Post ${i}` } }));
const data = Array.from({ length: 238 }).map((x, i) => ({ title: `Post ${i}` }));
// note this usage of the type is important because it tests that the generated
// KeystoneListsTypeInfo extends Record<string, BaseGeneratedListTypes>
const lists = context.lists as KeystoneListsAPI<KeystoneListsTypeInfo>;
Expand Down
56 changes: 14 additions & 42 deletions examples-staging/ecommerce/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ input UserCreateInput {
passwordResetRedeemedAt: String
}

input UsersCreateInput {
data: UserCreateInput
}

type Product {
id: ID!
name: String
Expand Down Expand Up @@ -269,10 +265,6 @@ input ProductCreateInput {
user: UserRelateToOneInput
}

input ProductsCreateInput {
data: ProductCreateInput
}

type ProductImage {
id: ID!
image: CloudinaryImage_File
Expand Down Expand Up @@ -392,10 +384,6 @@ input ProductImageCreateInput {
product: ProductRelateToOneInput
}

input ProductImagesCreateInput {
data: ProductImageCreateInput
}

type CartItem {
id: ID!
quantity: Int
Expand Down Expand Up @@ -454,10 +442,6 @@ input CartItemCreateInput {
user: UserRelateToOneInput
}

input CartItemsCreateInput {
data: CartItemCreateInput
}

type OrderItem {
id: ID!
name: String
Expand Down Expand Up @@ -555,10 +539,6 @@ input OrderItemCreateInput {
order: OrderRelateToOneInput
}

input OrderItemsCreateInput {
data: OrderItemCreateInput
}

type Order {
id: ID!
label: String
Expand Down Expand Up @@ -642,10 +622,6 @@ input OrderCreateInput {
charge: String
}

input OrdersCreateInput {
data: OrderCreateInput
}

type Role {
id: ID!
name: String
Expand Down Expand Up @@ -747,10 +723,6 @@ input RoleCreateInput {
assignedTo: UserRelateToManyInput
}

input RolesCreateInput {
data: RoleCreateInput
}

"""
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 @@ -760,44 +732,44 @@ scalar JSON
)

type Mutation {
createUser(data: UserCreateInput): User
createUsers(data: [UsersCreateInput]): [User]
createUser(data: UserCreateInput!): User
createUsers(data: [UserCreateInput!]!): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
createProduct(data: ProductCreateInput): Product
createProducts(data: [ProductsCreateInput]): [Product]
createProduct(data: ProductCreateInput!): Product
createProducts(data: [ProductCreateInput!]!): [Product]
updateProduct(id: ID!, data: ProductUpdateInput): Product
updateProducts(data: [ProductUpdateArgs]): [Product]
deleteProduct(where: ProductWhereUniqueInput!): Product
deleteProducts(where: [ProductWhereUniqueInput!]!): [Product]
createProductImage(data: ProductImageCreateInput): ProductImage
createProductImages(data: [ProductImagesCreateInput]): [ProductImage]
createProductImage(data: ProductImageCreateInput!): ProductImage
createProductImages(data: [ProductImageCreateInput!]!): [ProductImage]
updateProductImage(id: ID!, data: ProductImageUpdateInput): ProductImage
updateProductImages(data: [ProductImageUpdateArgs]): [ProductImage]
deleteProductImage(where: ProductImageWhereUniqueInput!): ProductImage
deleteProductImages(where: [ProductImageWhereUniqueInput!]!): [ProductImage]
createCartItem(data: CartItemCreateInput): CartItem
createCartItems(data: [CartItemsCreateInput]): [CartItem]
createCartItem(data: CartItemCreateInput!): CartItem
createCartItems(data: [CartItemCreateInput!]!): [CartItem]
updateCartItem(id: ID!, data: CartItemUpdateInput): CartItem
updateCartItems(data: [CartItemUpdateArgs]): [CartItem]
deleteCartItem(where: CartItemWhereUniqueInput!): CartItem
deleteCartItems(where: [CartItemWhereUniqueInput!]!): [CartItem]
createOrderItem(data: OrderItemCreateInput): OrderItem
createOrderItems(data: [OrderItemsCreateInput]): [OrderItem]
createOrderItem(data: OrderItemCreateInput!): OrderItem
createOrderItems(data: [OrderItemCreateInput!]!): [OrderItem]
updateOrderItem(id: ID!, data: OrderItemUpdateInput): OrderItem
updateOrderItems(data: [OrderItemUpdateArgs]): [OrderItem]
deleteOrderItem(where: OrderItemWhereUniqueInput!): OrderItem
deleteOrderItems(where: [OrderItemWhereUniqueInput!]!): [OrderItem]
createOrder(data: OrderCreateInput): Order
createOrders(data: [OrdersCreateInput]): [Order]
createOrder(data: OrderCreateInput!): Order
createOrders(data: [OrderCreateInput!]!): [Order]
updateOrder(id: ID!, data: OrderUpdateInput): Order
updateOrders(data: [OrderUpdateArgs]): [Order]
deleteOrder(where: OrderWhereUniqueInput!): Order
deleteOrders(where: [OrderWhereUniqueInput!]!): [Order]
createRole(data: RoleCreateInput): Role
createRoles(data: [RolesCreateInput]): [Role]
createRole(data: RoleCreateInput!): Role
createRoles(data: [RoleCreateInput!]!): [Role]
updateRole(id: ID!, data: RoleUpdateInput): Role
updateRoles(data: [RoleUpdateArgs]): [Role]
deleteRole(where: RoleWhereUniqueInput!): Role
Expand Down
8 changes: 2 additions & 6 deletions examples-staging/embedded-nextjs/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ input PostCreateInput {
content: String
}

input PostsCreateInput {
data: PostCreateInput
}

"""
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 @@ -82,8 +78,8 @@ scalar JSON
)

type Mutation {
createPost(data: PostCreateInput): Post
createPosts(data: [PostsCreateInput]): [Post]
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
Expand Down
24 changes: 6 additions & 18 deletions examples-staging/graphql-api-endpoint/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ input UserCreateInput {
posts: PostRelateToManyInput
}

input UsersCreateInput {
data: UserCreateInput
}

type Post {
id: ID!
title: String
Expand Down Expand Up @@ -231,10 +227,6 @@ input PostCreateInput {
tags: TagRelateToManyInput
}

input PostsCreateInput {
data: PostCreateInput
}

type Tag {
id: ID!
name: String
Expand Down Expand Up @@ -305,10 +297,6 @@ input TagCreateInput {
posts: PostRelateToManyInput
}

input TagsCreateInput {
data: TagCreateInput
}

"""
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 @@ -318,20 +306,20 @@ scalar JSON
)

type Mutation {
createUser(data: UserCreateInput): User
createUsers(data: [UsersCreateInput]): [User]
createUser(data: UserCreateInput!): User
createUsers(data: [UserCreateInput!]!): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
createPost(data: PostCreateInput): Post
createPosts(data: [PostsCreateInput]): [Post]
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createTag(data: TagCreateInput): Tag
createTags(data: [TagsCreateInput]): [Tag]
createTag(data: TagCreateInput!): Tag
createTags(data: [TagCreateInput!]!): [Tag]
updateTag(id: ID!, data: TagUpdateInput): Tag
updateTags(data: [TagUpdateArgs]): [Tag]
deleteTag(where: TagWhereUniqueInput!): Tag
Expand Down
Loading

1 comment on commit 092df66

@vercel
Copy link

@vercel vercel bot commented on 092df66 Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.