Skip to content

Commit

Permalink
Disable sorting on many relationships (#5622)
Browse files Browse the repository at this point in the history
Co-authored-by: Charles <cc.lee@live.com.au>
  • Loading branch information
timleslie and gwyneplaine committed May 6, 2021
1 parent b0a72a1 commit bb89208
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changeset/weak-ants-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@keystone-next/app-basic': patch
'@keystone-next/example-todo': patch
'@keystone-next/fields': patch
---

Disabled sorting for `many` relationship fields.
4 changes: 0 additions & 4 deletions examples/basic/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ enum SortUsersBy {
isAdmin_DESC
roles_ASC
roles_DESC
phoneNumbers_ASC
phoneNumbers_DESC
posts_ASC
posts_DESC
}

input UserUpdateInput {
Expand Down
2 changes: 0 additions & 2 deletions examples/todo/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ enum SortPeopleBy {
id_DESC
name_ASC
name_DESC
tasks_ASC
tasks_DESC
}

input PersonUpdateInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export class Relationship<P extends string> extends Implementation<P> {
const [refListKey, refFieldPath] = ref.split('.');
this.refListKey = refListKey;
this.refFieldPath = refFieldPath;
this.isOrderable = true;
// FIXME: In general we need to dig deeper on what it means to order by a relationship,
// but for now this lets us order one to many related items by their ID, which is
// an ok first approximation.
this.isOrderable = !many;

this.isRelationship = true;
this.many = !!many;
Expand Down

0 comments on commit bb89208

Please sign in to comment.