docs(graphql): pagination arguments (#111)

(cherry picked from commit bf69d27a98)
This commit is contained in:
Kyrch
2025-07-24 21:11:33 -03:00
committed by Maniload
parent d70bd55ace
commit f12b15c440
2 changed files with 75 additions and 51 deletions
+28 -41
View File
@@ -6,16 +6,19 @@ title: Filtering
--- ---
Most queries provide filtering arguments using the AND operator. Filtering arguments are built using `{fields}_{filter}`. Most queries provide filtering arguments using the AND operator. Filtering arguments are built using the `{fields}_{filter}` pattern.
## All Filters ## All Filters
* Eq: `name` (without the filter argument) | Name | Fields | Example | Description |
* Like: `name_like` | :-----: | :--------------------------------------------: | :--------: | ------------------------------------- |
* In: `id_in` | Eq | String, Int, Float, Boolean, enums, DateTimeTz | name | Add an `equal` conditional to the query |
* Not in: `id_not_in` | Like | String | name_like | Add a `like` conditional to the query |
* Greater: `id_greater` | In | Int, Float, enums | id_in | Add an `in` conditional to the query |
* Lesser: `id_lesser` | Not in | Int, Float, enums | id_not_in | Add a `not in` conditional to the query |
| Greater | Int, Float, DateTimeTz | id_greater | Add a `gt` conditional to the query |
| Lesser | Int, Float, DateTimeTz | id_lesser | Add a `lt` conditional to the query |
Query example: Query example:
```graphql ```graphql
@@ -28,45 +31,29 @@ query {
} }
``` ```
## Available Filters for the fields ## Trashed Filter
### String Fields The queries that return a type that implements soft-deletes have a `trashed` filter.
* Eq The argument is: `trashed: Trashed`, which allows to filter if trashed elements should be fetched.
* Like
### Int Fields `Trashed` is an enum with the following values:
* Eq | Value | Description |
* In | :----------: | :------------------------------------------- |
* Not in | ONLY | Only return trashed results. |
* Greater | WITH | Return both trashed and non-trashed results. |
* Lesser | WITHOUT | Only return non-trashed results. |
### Float Fields
* Eq
* In
* Not in
* Lesser
* Greater
### Boolean Fields
* Eq
### Enum Fields
* Eq
* In
* Not in
### DateTimeTz Fields
* Eq
* Greater
* Lesser
```graphql
query {
animes(trashed: ONLY) {
data {
name
}
}
}
```
## Nested Filtering ## Nested Filtering
+47 -10
View File
@@ -8,23 +8,60 @@ title: Pagination
The AnimeThemes API query that uses pagination shall contain a `paginatorInfo` object for pagination strategies and a `data` collection with the resources. The AnimeThemes API query that uses pagination shall contain a `paginatorInfo` object for pagination strategies and a `data` collection with the resources.
## Arguments
There are two arguments available for every query that uses pagination.
| Name | Type | Default | Max | Description |
| :-------: | :------: | :------: | :------: | ----------------------------------------- |
| first | Int! | 15 | 100 | Limits number of fetched items |
| page | Int | 1 | lastPage | The offset from which items are returned |
## Query
The following query
```graphql
query {
animes(first: 15, page: 1) {
paginatorInfo {
count
currentPage
firstItem
hasMorePages
lastItem
lastPage
perPage
total
}
data {
name
}
}
}
```
will return a JSON like:
```json ```json
// The animes query contains a paginatorInfo object
{ {
"data": { "data": {
"animes": { "animes": {
"paginatorInfo": { "paginatorInfo": {
"count": count, "count": 2,
"currentPage": currentPage, "currentPage": 1,
"firstItem": firstItem, "firstItem": 1,
"hasMorePages": hasMorePages, "hasMorePages": true,
"lastItem": lastItem, "lastItem": 2,
"lastPage": lastPage, "lastPage": 2317,
"perPage": perPage, "perPage": 2,
"total": total "total": 4633
}, },
"data": [ "data": [
... {
"name": ".hack//Liminality"
},
{
"name": ".hack//roots"
}
] ]
} }
} }