rdrgtec
rdrgtec

Reputation: 640

AWS GraphQL: Sort List by specific sort key

Considering the given schema declaration:

type Subject @model @key(fields: ["num", "type", "desc", "parent"])
{
    id:     ID!
    num :   String!
    ...
}

How would I call API.graphql method in order to sort it by its 3rd key, for instance?

Upvotes: 1

Views: 1261

Answers (1)

Jason Wadsworth
Jason Wadsworth

Reputation: 8887

GraphQL doesn't inherently support sorting. To add sorting you need to modify your queries to accept one or more sort parameters and then do the sorting in your code. This article gives examples of Filtering, Pagination & Sorting.

Upvotes: 1

Related Questions