Skip to content

Instantly share code, notes, and snippets.

@fer-ri
Created August 10, 2026 14:40
Show Gist options
  • Select an option

  • Save fer-ri/174b5337ba9536100541594eaafbdffe to your computer and use it in GitHub Desktop.

Select an option

Save fer-ri/174b5337ba9536100541594eaafbdffe to your computer and use it in GitHub Desktop.
Resolution for hris-backend issue #230 pagination bug

Issue #230 Resolution

Root Cause

Lighthouse @paginate correctly parses GraphQL first and page. However, fields using @paginate(resolver: ...) delegate paginator construction to custom resolvers.

The custom resolvers called Eloquent paginate() without arguments. Laravel then used its default page size of 15, so GraphQL pagination variables were ignored. Lighthouse's pagination.default_count setting does not configure an inner Laravel paginate() call.

This was a codebase integration bug, not a Lighthouse defect.

Fix

Updated all 18 custom paginated resolvers to pass GraphQL pagination values into Eloquent:

return $query->paginate(
    $args['first'],
    ['*'],
    'page',
    $args['page'] ?? 1,
);

This preserves existing authorization, filtering, ordering, eager loading, and enhanceBuilder() behavior. No manual LengthAwarePaginator construction is needed because Eloquent paginate() already returns one.

Coverage

  • Employee regression creates 31 records and traverses four pages with first: 10.
  • Assertions verify page counts, total, current page, last page, no overlap, and full reachability.
  • Representative pagination assertions cover employees, departments, inquiries, and internal users.

Verification

  • docker compose exec --user www-data app composer lint
  • docker compose exec --user www-data app composer test
  • Result: 666 passed, 1 skipped, 4,802 assertions.
  • codegraph sync completed.

Commit

3a0f2d6 fix(graphql): honor pagination args in custom resolvers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment