mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
f6ed169219
* allow ordering using columns from object relationships, close #463 * validate table fields in nested insert * add tests * add docs * change 'table_order_by' type from enums to ordered map * remove unwanted code from 'Schema.hs' file * 'AnnGObject' is not list of field name and value tuple * update docs for new order_by type * use 'InsOrdHashMap' for 'AnnGObj' * handle empty fields in order_by * remove '_' prefixes for asc/desc * fix the changed order_by syntax across the repo
106 lines
2.6 KiB
ReStructuredText
106 lines
2.6 KiB
ReStructuredText
Using multiple arguments in a query
|
|
===================================
|
|
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 ``order_by`` argument to sort them.
|
|
|
|
For example, fetch a list of authors and only 2 of their published articles that are sorted by their date of publication:
|
|
|
|
.. graphiql::
|
|
:view_only:
|
|
:query:
|
|
query {
|
|
author {
|
|
id
|
|
name
|
|
articles(
|
|
where: {is_published: {_eq: true}},
|
|
order_by: {published_on: desc},
|
|
limit: 2
|
|
) {
|
|
id
|
|
title
|
|
is_published
|
|
published_on
|
|
}
|
|
}
|
|
}
|
|
:response:
|
|
{
|
|
"data": {
|
|
"author": [
|
|
{
|
|
"id": 1,
|
|
"name": "Justin",
|
|
"articles": [
|
|
{
|
|
"is_published": true,
|
|
"id": 16,
|
|
"title": "sem duis aliquam",
|
|
"published_on": "2018-02-14"
|
|
},
|
|
{
|
|
"is_published": true,
|
|
"id": 15,
|
|
"title": "vel dapibus at",
|
|
"published_on": "2018-01-02"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Beltran",
|
|
"articles": [
|
|
{
|
|
"is_published": true,
|
|
"id": 2,
|
|
"title": "a nibh",
|
|
"published_on": "2018-06-10"
|
|
},
|
|
{
|
|
"is_published": true,
|
|
"id": 9,
|
|
"title": "sit amet",
|
|
"published_on": "2017-05-16"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"id": 3,
|
|
"name": "Sidney",
|
|
"articles": [
|
|
{
|
|
"is_published": true,
|
|
"id": 6,
|
|
"title": "sapien ut",
|
|
"published_on": "2018-01-08"
|
|
},
|
|
{
|
|
"is_published": true,
|
|
"id": 11,
|
|
"title": "turpis eget",
|
|
"published_on": "2017-04-14"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"id": 4,
|
|
"name": "Anjela",
|
|
"articles": [
|
|
{
|
|
"is_published": true,
|
|
"id": 1,
|
|
"title": "sit amet",
|
|
"published_on": "2017-08-09"
|
|
},
|
|
{
|
|
"is_published": true,
|
|
"id": 3,
|
|
"title": "amet justo morbi",
|
|
"published_on": "2017-05-26"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|