Skip to content

Commit

Permalink
To-one relationship input updates (#6217)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Jul 29, 2021
1 parent aac6e4d commit 874f2c4
Show file tree
Hide file tree
Showing 37 changed files with 363 additions and 548 deletions.
21 changes: 21 additions & 0 deletions .changeset/nasty-windows-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@keystone-next/fields': major
'@keystone-next/keystone': major
'@keystone-next/types': major
---

`disconnectAll` has been renamed to `disconnect` in to-one relationship inputs and the old `disconnect` field has been removed. There are also seperate input types for create and update where the input for create doesn't have `disconnect`. It's also now required that if you provide a to-one relationship input, you must provide exactly one field to the input.

If you have a list called `Item`, the to-one relationship inputs now look like this:

```graphql
input ItemRelateToOneForCreateInput {
create: ItemCreateInput
connect: ItemWhereUniqueInput
}
input ItemRelateToOneForUpdateInput {
create: ItemCreateInput
connect: ItemWhereUniqueInput
disconnect: Boolean
}
```
14 changes: 9 additions & 5 deletions examples-staging/assets-cloud/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,15 @@ input PostUpdateInput {
status: PostStatusType
content: String
publishDate: String
author: AuthorRelateToOneInput
author: AuthorRelateToOneForUpdateInput
hero: ImageFieldInput
attachment: FileFieldInput
}

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

input ImageFieldInput {
Expand Down Expand Up @@ -153,11 +152,16 @@ input PostCreateInput {
status: PostStatusType
content: String
publishDate: String
author: AuthorRelateToOneInput
author: AuthorRelateToOneForCreateInput
hero: ImageFieldInput
attachment: FileFieldInput
}

input AuthorRelateToOneForCreateInput {
create: AuthorCreateInput
connect: AuthorWhereUniqueInput
}

type Author {
id: ID!
name: String
Expand Down
14 changes: 9 additions & 5 deletions examples-staging/assets-local/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,14 @@ input PostUpdateInput {
status: PostStatusType
content: String
publishDate: String
author: AuthorRelateToOneInput
author: AuthorRelateToOneForUpdateInput
hero: ImageFieldInput
}

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

input ImageFieldInput {
Expand All @@ -132,10 +131,15 @@ input PostCreateInput {
status: PostStatusType
content: String
publishDate: String
author: AuthorRelateToOneInput
author: AuthorRelateToOneForCreateInput
hero: ImageFieldInput
}

input AuthorRelateToOneForCreateInput {
create: AuthorCreateInput
connect: AuthorWhereUniqueInput
}

type Author {
id: ID!
name: String
Expand Down
18 changes: 11 additions & 7 deletions examples-staging/basic/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,15 @@ input PhoneNumberOrderByInput {
}

input PhoneNumberUpdateInput {
user: UserRelateToOneInput
user: UserRelateToOneForUpdateInput
type: String
value: String
}

input UserRelateToOneInput {
input UserRelateToOneForUpdateInput {
create: UserCreateInput
connect: UserWhereUniqueInput
disconnect: UserWhereUniqueInput
disconnectAll: Boolean
disconnect: Boolean
}

input PhoneNumberUpdateArgs {
Expand All @@ -247,11 +246,16 @@ input PhoneNumberUpdateArgs {
}

input PhoneNumberCreateInput {
user: UserRelateToOneInput
user: UserRelateToOneForCreateInput
type: String
value: String
}

input UserRelateToOneForCreateInput {
create: UserCreateInput
connect: UserWhereUniqueInput
}

type Post {
id: ID!
title: String
Expand Down Expand Up @@ -314,7 +318,7 @@ input PostUpdateInput {
status: String
content: JSON
publishDate: String
author: UserRelateToOneInput
author: UserRelateToOneForUpdateInput
}

input PostUpdateArgs {
Expand All @@ -327,7 +331,7 @@ input PostCreateInput {
status: String
content: JSON
publishDate: String
author: UserRelateToOneInput
author: UserRelateToOneForCreateInput
}

"""
Expand Down
86 changes: 53 additions & 33 deletions examples-staging/ecommerce/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ input UserUpdateInput {
password: String
cart: CartItemRelateToManyInput
orders: OrderRelateToManyInput
role: RoleRelateToOneInput
role: RoleRelateToOneForUpdateInput
products: ProductRelateToManyInput
passwordResetToken: String
passwordResetIssuedAt: String
Expand All @@ -133,11 +133,10 @@ input OrderRelateToManyInput {
disconnectAll: Boolean
}

input RoleRelateToOneInput {
input RoleRelateToOneForUpdateInput {
create: RoleCreateInput
connect: RoleWhereUniqueInput
disconnect: RoleWhereUniqueInput
disconnectAll: Boolean
disconnect: Boolean
}

input ProductRelateToManyInput {
Expand All @@ -158,13 +157,18 @@ input UserCreateInput {
password: String
cart: CartItemRelateToManyInput
orders: OrderRelateToManyInput
role: RoleRelateToOneInput
role: RoleRelateToOneForCreateInput
products: ProductRelateToManyInput
passwordResetToken: String
passwordResetIssuedAt: String
passwordResetRedeemedAt: String
}

input RoleRelateToOneForCreateInput {
create: RoleCreateInput
connect: RoleWhereUniqueInput
}

type Product {
id: ID!
name: String
Expand Down Expand Up @@ -231,24 +235,22 @@ input ProductOrderByInput {
input ProductUpdateInput {
name: String
description: String
photo: ProductImageRelateToOneInput
photo: ProductImageRelateToOneForUpdateInput
status: String
price: Int
user: UserRelateToOneInput
user: UserRelateToOneForUpdateInput
}

input ProductImageRelateToOneInput {
input ProductImageRelateToOneForUpdateInput {
create: ProductImageCreateInput
connect: ProductImageWhereUniqueInput
disconnect: ProductImageWhereUniqueInput
disconnectAll: Boolean
disconnect: Boolean
}

input UserRelateToOneInput {
input UserRelateToOneForUpdateInput {
create: UserCreateInput
connect: UserWhereUniqueInput
disconnect: UserWhereUniqueInput
disconnectAll: Boolean
disconnect: Boolean
}

input ProductUpdateArgs {
Expand All @@ -259,10 +261,20 @@ input ProductUpdateArgs {
input ProductCreateInput {
name: String
description: String
photo: ProductImageRelateToOneInput
photo: ProductImageRelateToOneForCreateInput
status: String
price: Int
user: UserRelateToOneInput
user: UserRelateToOneForCreateInput
}

input ProductImageRelateToOneForCreateInput {
create: ProductImageCreateInput
connect: ProductImageWhereUniqueInput
}

input UserRelateToOneForCreateInput {
create: UserCreateInput
connect: UserWhereUniqueInput
}

type ProductImage {
Expand Down Expand Up @@ -358,19 +370,18 @@ input ProductImageOrderByInput {
input ProductImageUpdateInput {
image: Upload
altText: String
product: ProductRelateToOneInput
product: ProductRelateToOneForUpdateInput
}

"""
The `Upload` scalar type represents a file upload.
"""
scalar Upload

input ProductRelateToOneInput {
input ProductRelateToOneForUpdateInput {
create: ProductCreateInput
connect: ProductWhereUniqueInput
disconnect: ProductWhereUniqueInput
disconnectAll: Boolean
disconnect: Boolean
}

input ProductImageUpdateArgs {
Expand All @@ -381,7 +392,12 @@ input ProductImageUpdateArgs {
input ProductImageCreateInput {
image: Upload
altText: String
product: ProductRelateToOneInput
product: ProductRelateToOneForCreateInput
}

input ProductRelateToOneForCreateInput {
create: ProductCreateInput
connect: ProductWhereUniqueInput
}

type CartItem {
Expand Down Expand Up @@ -427,8 +443,8 @@ input CartItemOrderByInput {

input CartItemUpdateInput {
quantity: Int
product: ProductRelateToOneInput
user: UserRelateToOneInput
product: ProductRelateToOneForUpdateInput
user: UserRelateToOneForUpdateInput
}

input CartItemUpdateArgs {
Expand All @@ -438,8 +454,8 @@ input CartItemUpdateArgs {

input CartItemCreateInput {
quantity: Int
product: ProductRelateToOneInput
user: UserRelateToOneInput
product: ProductRelateToOneForCreateInput
user: UserRelateToOneForCreateInput
}

type OrderItem {
Expand Down Expand Up @@ -512,17 +528,16 @@ input OrderItemOrderByInput {
input OrderItemUpdateInput {
name: String
description: String
photo: ProductImageRelateToOneInput
photo: ProductImageRelateToOneForUpdateInput
price: Int
quantity: Int
order: OrderRelateToOneInput
order: OrderRelateToOneForUpdateInput
}

input OrderRelateToOneInput {
input OrderRelateToOneForUpdateInput {
create: OrderCreateInput
connect: OrderWhereUniqueInput
disconnect: OrderWhereUniqueInput
disconnectAll: Boolean
disconnect: Boolean
}

input OrderItemUpdateArgs {
Expand All @@ -533,10 +548,15 @@ input OrderItemUpdateArgs {
input OrderItemCreateInput {
name: String
description: String
photo: ProductImageRelateToOneInput
photo: ProductImageRelateToOneForCreateInput
price: Int
quantity: Int
order: OrderRelateToOneInput
order: OrderRelateToOneForCreateInput
}

input OrderRelateToOneForCreateInput {
create: OrderCreateInput
connect: OrderWhereUniqueInput
}

type Order {
Expand Down Expand Up @@ -599,7 +619,7 @@ input OrderOrderByInput {
input OrderUpdateInput {
total: Int
items: OrderItemRelateToManyInput
user: UserRelateToOneInput
user: UserRelateToOneForUpdateInput
charge: String
}

Expand All @@ -618,7 +638,7 @@ input OrderUpdateArgs {
input OrderCreateInput {
total: Int
items: OrderItemRelateToManyInput
user: UserRelateToOneInput
user: UserRelateToOneForCreateInput
charge: String
}

Expand Down
Loading

1 comment on commit 874f2c4

@vercel
Copy link

@vercel vercel bot commented on 874f2c4 Jul 29, 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.