2022-01-16

GraphQL - sort error - Unknown argument "sort"

I need your help in order to sort a GraphQL data by the field createdAt in descending order. When queering by ID, the API, doesn't allow you to sort the array of the given ID. If i remove the sort key, the query runs ok, but the data is in ascending order (older to new) and I need to retrieve all the new values.

Do you know how can I sort the array? Thank you in advance!

  query GetCategory{
    category(id: 4, sort: "createdAt:desc") {
      data
        {
          id
          attributes
          {
            name
            reviews{
              data
              {
                id
                attributes
                {
                  title
                  body
                  rating
                  createdAt
                  categories{
                    data
                    {
                      id
                      attributes{
                        name
                      }
                    }
                  }
                }
              }
            }
          }
        }
    }
  }



from Recent Questions - Stack Overflow https://ift.tt/3I3rAFS
https://ift.tt/eA8V8J

No comments:

Post a Comment