Skip to content

Commit

Permalink
To-many relationship input updates (#6224)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Jul 30, 2021
1 parent 8b2d179 commit 3564b34
Show file tree
Hide file tree
Showing 40 changed files with 677 additions and 458 deletions.
22 changes: 22 additions & 0 deletions .changeset/rich-tomatoes-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@keystone-next/fields': major
'@keystone-next/keystone': major
'@keystone-next/types': major
---

`disconnectAll` has been replaced by `set` in to-many relationship inputs, the equivalent to `disconnectAll: true` is now `set: []`. There are also seperate input types for create and update where the input for create doesn't have `disconnect` or `set`. The inputs in the lists in the input field are now also non-null.

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

```graphql
input ItemRelateToManyForCreateInput {
create: [ItemCreateInput!]
connect: [ItemWhereUniqueInput!]
}
input ItemRelateToManyForUpdateInput {
disconnect: [ItemWhereUniqueInput!]
set: [ItemWhereUniqueInput!]
create: [ItemCreateInput!]
connect: [ItemWhereUniqueInput!]
}
```
19 changes: 12 additions & 7 deletions examples-staging/assets-cloud/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ input AuthorOrderByInput {
input AuthorUpdateInput {
name: String
email: String
posts: PostRelateToManyInput
posts: PostRelateToManyForUpdateInput
}

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

input AuthorUpdateArgs {
Expand All @@ -235,7 +235,12 @@ input AuthorUpdateArgs {
input AuthorCreateInput {
name: String
email: String
posts: PostRelateToManyInput
posts: PostRelateToManyForCreateInput
}

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

"""
Expand Down
19 changes: 12 additions & 7 deletions examples-staging/assets-local/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ input AuthorOrderByInput {
input AuthorUpdateInput {
name: String
email: String
posts: PostRelateToManyInput
posts: PostRelateToManyForUpdateInput
}

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

input AuthorUpdateArgs {
Expand All @@ -213,7 +213,12 @@ input AuthorUpdateArgs {
input AuthorCreateInput {
name: String
email: String
posts: PostRelateToManyInput
posts: PostRelateToManyForCreateInput
}

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

"""
Expand Down
38 changes: 24 additions & 14 deletions examples-staging/basic/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ input UserUpdateInput {
password: String
isAdmin: Boolean
roles: String
phoneNumbers: PhoneNumberRelateToManyInput
posts: PostRelateToManyInput
phoneNumbers: PhoneNumberRelateToManyForUpdateInput
posts: PostRelateToManyForUpdateInput
}

input ImageFieldInput {
Expand All @@ -154,18 +154,18 @@ input FileFieldInput {
ref: String
}

input PhoneNumberRelateToManyInput {
create: [PhoneNumberCreateInput]
connect: [PhoneNumberWhereUniqueInput]
disconnect: [PhoneNumberWhereUniqueInput]
disconnectAll: Boolean
input PhoneNumberRelateToManyForUpdateInput {
disconnect: [PhoneNumberWhereUniqueInput!]
set: [PhoneNumberWhereUniqueInput!]
create: [PhoneNumberCreateInput!]
connect: [PhoneNumberWhereUniqueInput!]
}

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

input UserUpdateArgs {
Expand All @@ -181,8 +181,18 @@ input UserCreateInput {
password: String
isAdmin: Boolean
roles: String
phoneNumbers: PhoneNumberRelateToManyInput
posts: PostRelateToManyInput
phoneNumbers: PhoneNumberRelateToManyForCreateInput
posts: PostRelateToManyForCreateInput
}

input PhoneNumberRelateToManyForCreateInput {
create: [PhoneNumberCreateInput!]
connect: [PhoneNumberWhereUniqueInput!]
}

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

type PhoneNumber {
Expand Down
95 changes: 60 additions & 35 deletions examples-staging/ecommerce/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,27 @@ input UserUpdateInput {
name: String
email: String
password: String
cart: CartItemRelateToManyInput
orders: OrderRelateToManyInput
cart: CartItemRelateToManyForUpdateInput
orders: OrderRelateToManyForUpdateInput
role: RoleRelateToOneForUpdateInput
products: ProductRelateToManyInput
products: ProductRelateToManyForUpdateInput
passwordResetToken: String
passwordResetIssuedAt: String
passwordResetRedeemedAt: String
}

input CartItemRelateToManyInput {
create: [CartItemCreateInput]
connect: [CartItemWhereUniqueInput]
disconnect: [CartItemWhereUniqueInput]
disconnectAll: Boolean
input CartItemRelateToManyForUpdateInput {
disconnect: [CartItemWhereUniqueInput!]
set: [CartItemWhereUniqueInput!]
create: [CartItemCreateInput!]
connect: [CartItemWhereUniqueInput!]
}

input OrderRelateToManyInput {
create: [OrderCreateInput]
connect: [OrderWhereUniqueInput]
disconnect: [OrderWhereUniqueInput]
disconnectAll: Boolean
input OrderRelateToManyForUpdateInput {
disconnect: [OrderWhereUniqueInput!]
set: [OrderWhereUniqueInput!]
create: [OrderCreateInput!]
connect: [OrderWhereUniqueInput!]
}

input RoleRelateToOneForUpdateInput {
Expand All @@ -139,11 +139,11 @@ input RoleRelateToOneForUpdateInput {
disconnect: Boolean
}

input ProductRelateToManyInput {
create: [ProductCreateInput]
connect: [ProductWhereUniqueInput]
disconnect: [ProductWhereUniqueInput]
disconnectAll: Boolean
input ProductRelateToManyForUpdateInput {
disconnect: [ProductWhereUniqueInput!]
set: [ProductWhereUniqueInput!]
create: [ProductCreateInput!]
connect: [ProductWhereUniqueInput!]
}

input UserUpdateArgs {
Expand All @@ -155,20 +155,35 @@ input UserCreateInput {
name: String
email: String
password: String
cart: CartItemRelateToManyInput
orders: OrderRelateToManyInput
cart: CartItemRelateToManyForCreateInput
orders: OrderRelateToManyForCreateInput
role: RoleRelateToOneForCreateInput
products: ProductRelateToManyInput
products: ProductRelateToManyForCreateInput
passwordResetToken: String
passwordResetIssuedAt: String
passwordResetRedeemedAt: String
}

input CartItemRelateToManyForCreateInput {
create: [CartItemCreateInput!]
connect: [CartItemWhereUniqueInput!]
}

input OrderRelateToManyForCreateInput {
create: [OrderCreateInput!]
connect: [OrderWhereUniqueInput!]
}

input RoleRelateToOneForCreateInput {
create: RoleCreateInput
connect: RoleWhereUniqueInput
}

input ProductRelateToManyForCreateInput {
create: [ProductCreateInput!]
connect: [ProductWhereUniqueInput!]
}

type Product {
id: ID!
name: String
Expand Down Expand Up @@ -618,16 +633,16 @@ input OrderOrderByInput {

input OrderUpdateInput {
total: Int
items: OrderItemRelateToManyInput
items: OrderItemRelateToManyForUpdateInput
user: UserRelateToOneForUpdateInput
charge: String
}

input OrderItemRelateToManyInput {
create: [OrderItemCreateInput]
connect: [OrderItemWhereUniqueInput]
disconnect: [OrderItemWhereUniqueInput]
disconnectAll: Boolean
input OrderItemRelateToManyForUpdateInput {
disconnect: [OrderItemWhereUniqueInput!]
set: [OrderItemWhereUniqueInput!]
create: [OrderItemCreateInput!]
connect: [OrderItemWhereUniqueInput!]
}

input OrderUpdateArgs {
Expand All @@ -637,11 +652,16 @@ input OrderUpdateArgs {

input OrderCreateInput {
total: Int
items: OrderItemRelateToManyInput
items: OrderItemRelateToManyForCreateInput
user: UserRelateToOneForCreateInput
charge: String
}

input OrderItemRelateToManyForCreateInput {
create: [OrderItemCreateInput!]
connect: [OrderItemWhereUniqueInput!]
}

type Role {
id: ID!
name: String
Expand Down Expand Up @@ -717,14 +737,14 @@ input RoleUpdateInput {
canManageRoles: Boolean
canManageCart: Boolean
canManageOrders: Boolean
assignedTo: UserRelateToManyInput
assignedTo: UserRelateToManyForUpdateInput
}

input UserRelateToManyInput {
create: [UserCreateInput]
connect: [UserWhereUniqueInput]
disconnect: [UserWhereUniqueInput]
disconnectAll: Boolean
input UserRelateToManyForUpdateInput {
disconnect: [UserWhereUniqueInput!]
set: [UserWhereUniqueInput!]
create: [UserCreateInput!]
connect: [UserWhereUniqueInput!]
}

input RoleUpdateArgs {
Expand All @@ -740,7 +760,12 @@ input RoleCreateInput {
canManageRoles: Boolean
canManageCart: Boolean
canManageOrders: Boolean
assignedTo: UserRelateToManyInput
assignedTo: UserRelateToManyForCreateInput
}

input UserRelateToManyForCreateInput {
create: [UserCreateInput!]
connect: [UserWhereUniqueInput!]
}

"""
Expand Down
Loading

1 comment on commit 3564b34

@vercel
Copy link

@vercel vercel bot commented on 3564b34 Jul 30, 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.