strapi icon indicating copy to clipboard operation
strapi copied to clipboard

GraphQL Plugin: sorting isn't typed accurately

Open YassinEldeeb opened this issue 3 years ago • 0 comments

The getting started template on this repo works great as a reproducible example: https://github.com/strapi/strapi/tree/main/examples/getstarted

Bug report

Required System information

  • Node.js version: 16.17.0
  • NPM version: 8.15.0
  • Strapi version: 4.3.6
  • Database: PostgreSQL
  • Operating system: MacOS

Describe the bug

When sorting there's no type-safety, you just type a string and hope that it's a field. a possible improvement for this would be to generate all of the fields combined with DESC and ASC as enum variants in the graphql schema

Steps to reproduce the behavior

  1. Go to http://localhost:1337/graphql
  2. Query a content type and try to sort it
  3. It's of type [String] so no auto-completion/validation is provided

Expected behavior

I think this is a much better experience

{
    movies(sort: [rating_ASC, date_DESC]) {...}
}

Screenshots

Untitled

YassinEldeeb avatar Oct 17 '22 08:10 YassinEldeeb