Skip to content

Pagination

This field extension allows you to use the default offset limit pagination provided by strawberry-graphql-django but wraps the results with total count.

Usage

1
2
3
4
5
6
7
8
9
import strawberry
import strawberry_django
from strawberry_django_extras.field_extensions import with_total_count

@strawberry.type
class Query:
    Users: list[UserType] = strawberry_django.field( 
        extensions=[with_total_count()]
    )

Now you can query your list with pagination and total count:

{
  Users(pagination: {offset:0 , limit:1} , order: {lastname: DESC} ) {
    results {
      id
      lastname
      firstname
      email  
    }
    totalCount
  }
}