1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of laravel.su package. |
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
5
|
|
|
* file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
declare(strict_types=1); |
8
|
|
|
|
9
|
|
|
namespace App\GraphQL\Types; |
10
|
|
|
|
11
|
|
|
use GraphQL\Type\Definition\Type; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class PaginatorType |
15
|
|
|
* @package App\GraphQL\Types |
16
|
|
|
*/ |
17
|
|
|
class PaginatorType extends AbstractType |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
protected $attributes = [ |
23
|
|
|
'name' => 'Paginator', |
24
|
|
|
'description' => 'Paginator type', |
25
|
|
|
]; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return array |
29
|
|
|
*/ |
30
|
|
|
public function fields(): array |
31
|
|
|
{ |
32
|
|
|
return [ |
33
|
|
|
'total_count' => [ |
34
|
|
|
'type' => Type::nonNull(Type::int()), |
35
|
|
|
'description' => 'Total count of elements', |
36
|
|
|
], |
37
|
|
|
'pages_count' => [ |
38
|
|
|
'type' => Type::nonNull(Type::int()), |
39
|
|
|
'description' => 'Total count of pages', |
40
|
|
|
], |
41
|
|
|
'per_page' => [ |
42
|
|
|
'type' => Type::nonNull(Type::int()), |
43
|
|
|
'description' => 'Count of elements in current page', |
44
|
|
|
], |
45
|
|
|
'limit' => [ |
46
|
|
|
'type' => Type::nonNull(Type::int()), |
47
|
|
|
'description' => 'Limit request query argument', |
48
|
|
|
], |
49
|
|
|
'skip' => [ |
50
|
|
|
'type' => Type::nonNull(Type::int()), |
51
|
|
|
'description' => 'Skip request query argument', |
52
|
|
|
], |
53
|
|
|
'page' => [ |
54
|
|
|
'type' => Type::nonNull(Type::int()), |
55
|
|
|
'description' => 'Page request query argument', |
56
|
|
|
], |
57
|
|
|
'is_first_page' => [ |
58
|
|
|
'type' => Type::nonNull(Type::boolean()), |
59
|
|
|
'description' => 'Bool is first page', |
60
|
|
|
], |
61
|
|
|
'is_last_page' => [ |
62
|
|
|
'type' => Type::nonNull(Type::boolean()), |
63
|
|
|
'description' => 'Bool is last page', |
64
|
|
|
], |
65
|
|
|
]; |
66
|
|
|
} |
67
|
|
|
} |