mirror of
https://github.com/AnimeThemes/animethemes-api-docs.git
synced 2026-07-11 01:34:06 +02:00
docs(graphql): pagination arguments (#111)
(cherry picked from commit bf69d27a98)
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user