Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GraphQL API updates #6211

Merged
merged 8 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .changeset/wet-frogs-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@keystone-next/auth': major
'@keystone-next/fields': major
'@keystone-next/keystone': major
'@keystone-next/types': major
---

The update mutations now accept `where` unique inputs instead of only an `id` and the `where` and `data` arguments are non-null.

If you have a list called `Item`, the update mutations now look like this:

```graphql
type Mutation {
updateItem(where: ItemWhereUniqueInput!, data: ItemUpdateInput!): Item
updateItems(data: [ItemUpdateArgs!]!): [Item]
}

input ItemUpdateArgs {
where: ItemWhereUniqueInput!
data: ItemUpdateInput!
}
```
16 changes: 8 additions & 8 deletions examples-staging/assets-cloud/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ input FileFieldInput {
}

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

input PostCreateInput {
Expand Down Expand Up @@ -224,8 +224,8 @@ input PostRelateToManyInput {
}

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

input AuthorCreateInput {
Expand All @@ -245,14 +245,14 @@ scalar JSON
type Mutation {
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [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(id: ID!, data: AuthorUpdateInput): Author
updateAuthors(data: [AuthorUpdateArgs]): [Author]
updateAuthor(where: AuthorWhereUniqueInput!, data: AuthorUpdateInput!): Author
updateAuthors(data: [AuthorUpdateArgs!]!): [Author]
deleteAuthor(where: AuthorWhereUniqueInput!): Author
deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author]
}
Expand Down
16 changes: 8 additions & 8 deletions examples-staging/assets-local/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ The `Upload` scalar type represents a file upload.
scalar Upload

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

input PostCreateInput {
Expand Down Expand Up @@ -202,8 +202,8 @@ input PostRelateToManyInput {
}

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

input AuthorCreateInput {
Expand All @@ -223,14 +223,14 @@ scalar JSON
type Mutation {
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [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(id: ID!, data: AuthorUpdateInput): Author
updateAuthors(data: [AuthorUpdateArgs]): [Author]
updateAuthor(where: AuthorWhereUniqueInput!, data: AuthorUpdateInput!): Author
updateAuthors(data: [AuthorUpdateArgs!]!): [Author]
deleteAuthor(where: AuthorWhereUniqueInput!): Author
deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author]
}
Expand Down
8 changes: 4 additions & 4 deletions examples-staging/auth/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ input UserUpdateInput {
}

input UserUpdateArgs {
id: ID!
data: UserUpdateInput
where: UserWhereUniqueInput!
data: UserUpdateInput!
}

input UserCreateInput {
Expand All @@ -85,8 +85,8 @@ scalar JSON
type Mutation {
createUser(data: UserCreateInput!): User
createUsers(data: [UserCreateInput!]!): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User
updateUsers(data: [UserUpdateArgs!]!): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
authenticateUserWithPassword(
Expand Down
27 changes: 15 additions & 12 deletions examples-staging/basic/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ input PostRelateToManyInput {
}

input UserUpdateArgs {
id: ID!
data: UserUpdateInput
where: UserWhereUniqueInput!
data: UserUpdateInput!
}

input UserCreateInput {
Expand Down Expand Up @@ -242,8 +242,8 @@ input UserRelateToOneInput {
}

input PhoneNumberUpdateArgs {
id: ID!
data: PhoneNumberUpdateInput
where: PhoneNumberWhereUniqueInput!
data: PhoneNumberUpdateInput!
}

input PhoneNumberCreateInput {
Expand Down Expand Up @@ -318,8 +318,8 @@ input PostUpdateInput {
}

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

input PostCreateInput {
Expand All @@ -341,20 +341,23 @@ scalar JSON
type Mutation {
createUser(data: UserCreateInput!): User
createUsers(data: [UserCreateInput!]!): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
updateUser(where: UserWhereUniqueInput!, data: UserUpdateInput!): User
updateUsers(data: [UserUpdateArgs!]!): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
createPhoneNumber(data: PhoneNumberCreateInput!): PhoneNumber
createPhoneNumbers(data: [PhoneNumberCreateInput!]!): [PhoneNumber]
updatePhoneNumber(id: ID!, data: PhoneNumberUpdateInput): PhoneNumber
updatePhoneNumbers(data: [PhoneNumberUpdateArgs]): [PhoneNumber]
updatePhoneNumber(
where: PhoneNumberWhereUniqueInput!
data: PhoneNumberUpdateInput!
): PhoneNumber
updatePhoneNumbers(data: [PhoneNumberUpdateArgs!]!): [PhoneNumber]
deletePhoneNumber(where: PhoneNumberWhereUniqueInput!): PhoneNumber
deletePhoneNumbers(where: [PhoneNumberWhereUniqueInput!]!): [PhoneNumber]
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post
updatePosts(data: [PostUpdateArgs!]!): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
authenticateUserWithPassword(
Expand Down
2 changes: 1 addition & 1 deletion examples-staging/ecommerce/mutations/addToCart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function addToCart(
// 3. See if the current item is in their cart
// 4. if itis, increment by 1
return await context.db.lists.CartItem.updateOne({
id: existingCartItem.id,
where: { id: existingCartItem.id },
data: { quantity: existingCartItem.quantity + 1 },
});
}
Expand Down
68 changes: 40 additions & 28 deletions examples-staging/ecommerce/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ input ProductRelateToManyInput {
}

input UserUpdateArgs {
id: ID!
data: UserUpdateInput
where: UserWhereUniqueInput!
data: UserUpdateInput!
}

input UserCreateInput {
Expand Down Expand Up @@ -252,8 +252,8 @@ input UserRelateToOneInput {
}

input ProductUpdateArgs {
id: ID!
data: ProductUpdateInput
where: ProductWhereUniqueInput!
data: ProductUpdateInput!
}

input ProductCreateInput {
Expand Down Expand Up @@ -374,8 +374,8 @@ input ProductRelateToOneInput {
}

input ProductImageUpdateArgs {
id: ID!
data: ProductImageUpdateInput
where: ProductImageWhereUniqueInput!
data: ProductImageUpdateInput!
}

input ProductImageCreateInput {
Expand Down Expand Up @@ -432,8 +432,8 @@ input CartItemUpdateInput {
}

input CartItemUpdateArgs {
id: ID!
data: CartItemUpdateInput
where: CartItemWhereUniqueInput!
data: CartItemUpdateInput!
}

input CartItemCreateInput {
Expand Down Expand Up @@ -526,8 +526,8 @@ input OrderRelateToOneInput {
}

input OrderItemUpdateArgs {
id: ID!
data: OrderItemUpdateInput
where: OrderItemWhereUniqueInput!
data: OrderItemUpdateInput!
}

input OrderItemCreateInput {
Expand Down Expand Up @@ -611,8 +611,8 @@ input OrderItemRelateToManyInput {
}

input OrderUpdateArgs {
id: ID!
data: OrderUpdateInput
where: OrderWhereUniqueInput!
data: OrderUpdateInput!
}

input OrderCreateInput {
Expand Down Expand Up @@ -708,8 +708,8 @@ input UserRelateToManyInput {
}

input RoleUpdateArgs {
id: ID!
data: RoleUpdateInput
where: RoleWhereUniqueInput!
data: RoleUpdateInput!
}

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

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

input PostCreateInput {
Expand All @@ -80,8 +80,8 @@ scalar JSON
type Mutation {
createPost(data: PostCreateInput!): Post
createPosts(data: [PostCreateInput!]!): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
updatePost(where: PostWhereUniqueInput!, data: PostUpdateInput!): Post
updatePosts(data: [PostUpdateArgs!]!): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
}
Expand Down
Loading