nuwave / nuwave/lighthouse

Add `Paginator` interface to all paginated fields

Open
#936 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
3.5k
Forks
468
Avg merge
3h 9m
Merged PRs (30d)
2

Description

I am willing to work on this feature if someone could provide the necessary context to get me going.

Is your feature request related to a problem? Please describe.
I am trying to use fragments to extract information from the paginatorInfo field on multiple paginated fields but, as it stands, Lighthouse generates a unique type for each paginated field:

# Example of such a type
type VideoPaginator {
  paginatorInfo: PaginatorInfo!
  data: [Video!]!
}

Describe the solution you'd like
I suggest we add an interface to the generated types called Paginator:

union Paginated = Video | Post | ... #all fields with @paginated would appear here

interface Paginator {
  paginatorInfo: PaginatorInfo!
  data: [Paginated!]!
}

type VideoPaginator implements Paginator {
  paginatorInfo: PaginatorInfo!
  data: [Video!]!
}

Describe alternatives you've considered

I have not considered any other solutions but would love to hear other's ideas.

A brief outline of how to approach this problem in the context of the internal workings of Lighthouse would be helpful as I am not familiar with how things work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the generated paginator types and the @paginated directive in Lighthouse, then trace how their fields and GraphQL types are assembled. The issue's proposed Paginator interface and shared fragment behavior define the desired outcome, but alternative designs and the exact affected entry points still need investigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, laravel, php
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.