Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix types for paginator #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Mappers/PaginatorTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,54 +104,54 @@ private function getObjectType(bool $countable, OutputType $subType): MutableInt
'firstItem' => [
'type' => Type::int(),
'description' => 'Get the "index" of the first item being paginated.',
'resolve' => static function (Paginator $root): int {
'resolve' => static function (Paginator $root): ?int {
return $root->firstItem();
},
],
'lastItem' => [
'type' => Type::int(),
'description' => 'Get the "index" of the last item being paginated.',
'resolve' => static function (Paginator $root): int {
'resolve' => static function (Paginator $root): ?int {
return $root->lastItem();
},
],
'hasMorePages' => [
'type' => Type::boolean(),
'type' => Type::nonNull(Type::boolean()),
'description' => 'Determine if there are more items in the data source.',
'resolve' => static function (Paginator $root): bool {
return $root->hasMorePages();
},
],
'perPage' => [
'type' => Type::int(),
'type' => Type::nonNull(Type::int()),
'description' => 'Get the number of items shown per page.',
'resolve' => static function (Paginator $root): int {
return $root->perPage();
},
],
'hasPages' => [
'type' => Type::boolean(),
'type' => Type::nonNull(Type::boolean()),
'description' => 'Determine if there are enough items to split into multiple pages.',
'resolve' => static function (Paginator $root): bool {
return $root->hasPages();
},
],
'currentPage' => [
'type' => Type::int(),
'type' => Type::nonNull(Type::int()),
'description' => 'Determine the current page being paginated.',
'resolve' => static function (Paginator $root): int {
return $root->currentPage();
},
],
'isEmpty' => [
'type' => Type::boolean(),
'type' => Type::nonNull(Type::boolean()),
'description' => 'Determine if the list of items is empty or not.',
'resolve' => static function (Paginator $root): bool {
return $root->isEmpty();
},
],
'isNotEmpty' => [
'type' => Type::boolean(),
'type' => Type::nonNull(Type::boolean()),
'description' => 'Determine if the list of items is not empty.',
'resolve' => static function (Paginator $root): bool {
return $root->isNotEmpty();
Expand All @@ -161,13 +161,13 @@ private function getObjectType(bool $countable, OutputType $subType): MutableInt

if ($countable) {
$fields['totalCount'] = [
'type' => Type::int(),
'type' => Type::nonNull(Type::int()),
'description' => 'The total count of items.',
'resolve' => static function (LengthAwarePaginator $root): int {
return $root->total();
}];
$fields['lastPage'] = [
'type' => Type::int(),
'type' => Type::nonNull(Type::int()),
'description' => 'Get the page number of the last available page.',
'resolve' => static function (LengthAwarePaginator $root): int {
return $root->lastPage();
Expand Down
Loading