From c882fd4bf270829e914e0b428a26cbcdcf8e2517 Mon Sep 17 00:00:00 2001 From: Seifane Idouchach Date: Thu, 26 Dec 2024 15:21:27 +0800 Subject: [PATCH 1/2] Fix types for Paginator --- src/Mappers/PaginatorTypeMapper.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Mappers/PaginatorTypeMapper.php b/src/Mappers/PaginatorTypeMapper.php index e110a77..5f9ef02 100644 --- a/src/Mappers/PaginatorTypeMapper.php +++ b/src/Mappers/PaginatorTypeMapper.php @@ -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(); From a8aa501c09c46321203ceb4336373e29f150fdad Mon Sep 17 00:00:00 2001 From: Seifane Idouchach Date: Thu, 26 Dec 2024 15:24:51 +0800 Subject: [PATCH 2/2] Fix types for Paginator --- src/Mappers/PaginatorTypeMapper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mappers/PaginatorTypeMapper.php b/src/Mappers/PaginatorTypeMapper.php index 5f9ef02..b242c5f 100644 --- a/src/Mappers/PaginatorTypeMapper.php +++ b/src/Mappers/PaginatorTypeMapper.php @@ -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();