2

I want to create a generic Strawberry type for a pagination result:

T = TypeVar('T')

@strawberry.type
class CursorPaginationResult(Generic[T]):
    rows: List[T]
    next: str

This seems to work but i would like CursorPaginationResult to be a subclass of StrawberryContainer so that it can be unwrapped by strawberry-django. Is there a way to do this?

I intend to use this type like this:

@strawberry.type
class ImtesQuery:
    items: CursorPaginationResult[Item] = CustomStrawberryDjangoField()

CustomStrawberryDjangoField would be a subclass of StrawberryDjangoField and take care the pagination logic and add arguments for limit and cursor.

cbergmiller
  • 278
  • 1
  • 10
  • 2
    I think this is something that will be supported when this PR lands: https://github.com/strawberry-graphql/strawberry/pull/1100 – patrick Aug 22 '21 at 14:54

0 Answers0