Skip to content

Use multiple arguments

Igor Dianov edited this page May 29, 2024 · 2 revisions

Multiple arguments can be used together in the same query.

For example, you can use the where argument to filter the results and then use the orderBy argument to sort by fields.

For example, fetch a list of authors and only 2 of their published books that are sorted by their date of publication:

{
  Authors(where: {name: {EQ: "Leo Tolstoy"}}) {
    select {
      id
      name
      books {
        id
        title
        publicationDate(orderBy: ASC)
      }
    }
  }
}
{
  "data": {
    "Authors": {
      "select": [
        {
          "id": 1,
          "name": "Leo Tolstoy",
          "books": [
            {
              "id": 2,
              "title": "War and Peace",
              "publicationDate": "1868-12-31"
            },
            {
              "id": 3,
              "title": "Anna Karenina",
              "publicationDate": "1877-03-31"
            }
          ]
        }
      ]
    }
  }
}