-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Labels
issue: bugIssue reporting a bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solveIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:databaseSource is core/database packageSource is core/database packagesource: plugin:graphqlSource is plugin/graphql packageSource is plugin/graphql packagestatus: confirmedConfirmed by a Strapi Team member or multiple community membersConfirmed by a Strapi Team member or multiple community members
Description
Describe the bug
Applying a sort: field:direction does not work in a GraphQL query that is attempting to sort on a manyWay relation.
Steps to reproduce the behavior
- Create two models: Article and Comment
- Create a many way relation between them where "Article has many Comments"
- Using the playground, attempt to query all articles and try to sort the comments by one of the fields in any direction
- See no change has occurred and the sort isn't passed into the Knex Query
Expected behavior
A sort param is passed into Knex and thus the result is sorted
Screenshots
Code snippets
GraphQL Query
query {
articles {
id
title
body
comments (sort: "text:asc"){
id
text
}
}
}
Article Model
{
"kind": "collectionType",
"collectionName": "articles",
"info": {
"name": "article"
},
"options": {
"increments": true,
"timestamps": true
},
"attributes": {
"title": {
"type": "string"
},
"body": {
"type": "richtext"
},
"comments": {
"collection": "comment"
}
}
}Comment Model
{
"kind": "collectionType",
"collectionName": "comments",
"info": {
"name": "comment"
},
"options": {
"increments": true,
"timestamps": true
},
"attributes": {
"text": {
"type": "string"
}
}
}System
- Node.js version: 12.18.3
- NPM version: 6.14.6
- Strapi version: 3.1.6
- Database: SQLite
- Operating system: Linux Mint 20 - ulyana (Ubuntu 20.04)
Additional context
Knex log for sort by text:asc
{
method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [ 100 ],
__knexQueryUid: '8b7c8ac2-6a72-4eaa-88aa-466fa5588dd1',
sql: 'select `articles`.* from `articles` limit ?'
}
{
method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [ 1 ],
__knexQueryUid: '68705428-42f4-45e8-9c1b-425ec6d7061c',
sql: 'select distinct `comments`.*, `articles__comments`.`article_id` as `_pivot_article_id`, `articles__comments`.`comment_id` as `_pivot_comment_id` from `comments` inner join `articles__comments` on `articles__comments`.`comment_id` = `comments`.`id` where `articles__comments`.`article_id` in (?)'
}
Knex log for sort by text:desc
{
method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [ 100 ],
__knexQueryUid: '6110d263-d52f-452a-b49e-99f599677dc6',
sql: 'select `articles`.* from `articles` limit ?'
}
{
method: 'select',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [ 1 ],
__knexQueryUid: '6ef13c28-01d1-4bc6-b057-7a8ec32bbb97',
sql: 'select distinct `comments`.*, `articles__comments`.`article_id` as `_pivot_article_id`, `articles__comments`.`comment_id` as `_pivot_comment_id` from `comments` inner join `articles__comments` on `articles__comments`.`comment_id` = `comments`.`id` where `articles__comments`.`article_id` in (?)'
}
georgekarapi
Metadata
Metadata
Assignees
Labels
issue: bugIssue reporting a bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solveIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:databaseSource is core/database packageSource is core/database packagesource: plugin:graphqlSource is plugin/graphql packageSource is plugin/graphql packagestatus: confirmedConfirmed by a Strapi Team member or multiple community membersConfirmed by a Strapi Team member or multiple community members

