Skip to content

Commit

Permalink
Disable ordering for all relationships (#5625)
Browse files Browse the repository at this point in the history
* Disable ordering for all relationships

* Fix test
  • Loading branch information
timleslie committed May 6, 2021
1 parent 11814ce commit f91e776
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .changeset/weak-ants-work.md
Expand Up @@ -4,4 +4,4 @@
'@keystone-next/fields': patch
---

Disabled sorting for `many` relationship fields.
Disabled sorting for relationship fields.
4 changes: 0 additions & 4 deletions examples/basic/schema.graphql
Expand Up @@ -274,8 +274,6 @@ input PhoneNumberWhereUniqueInput {
enum SortPhoneNumbersBy {
id_ASC
id_DESC
user_ASC
user_DESC
type_ASC
type_DESC
value_ASC
Expand Down Expand Up @@ -365,8 +363,6 @@ enum SortPostsBy {
status_DESC
publishDate_ASC
publishDate_DESC
author_ASC
author_DESC
}

input PostUpdateInput {
Expand Down
2 changes: 0 additions & 2 deletions examples/todo/schema.graphql
Expand Up @@ -71,8 +71,6 @@ enum SortTasksBy {
priority_DESC
isComplete_ASC
isComplete_DESC
assignedTo_ASC
assignedTo_DESC
finishBy_ASC
finishBy_DESC
}
Expand Down
8 changes: 4 additions & 4 deletions packages-next/fields/src/types/relationship/Implementation.ts
Expand Up @@ -42,10 +42,10 @@ export class Relationship<P extends string> extends Implementation<P> {
const [refListKey, refFieldPath] = ref.split('.');
this.refListKey = refListKey;
this.refFieldPath = refFieldPath;
// 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;
// FIXME: We should be able to sort by the "one" side of a relationship
// but for now this isn't actually implemented, so we explicitly disable
// ordering here.
this.isOrderable = false;

this.isRelationship = true;
this.many = !!many;
Expand Down
2 changes: 0 additions & 2 deletions packages-next/keystone/src/lib/core/tests/List.test.ts
Expand Up @@ -398,8 +398,6 @@ describe(`getGqlTypes()`, () => {
name_DESC
email_ASC
email_DESC
other_ASC
other_DESC
writeOnce_ASC
writeOnce_DESC
}`;
Expand Down

1 comment on commit f91e776

@vercel
Copy link

@vercel vercel bot commented on f91e776 May 6, 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.