Pagination metadata for graphql #11295

Open
opened 2025-12-29 21:43:10 +01:00 by adam · 6 comments
Owner

Originally created by @patrickfnielsen on GitHub (Jun 19, 2025).

NetBox version

v4.3.2

Feature type

Change to existing functionality

Proposed functionality

NetBox v4.3.0 introduced pagination in GraphQL.
I would like to propose that we include support for a "metadata" object containing record counts, like there is in the rest api.

It could look like this:

    page_metdata {
      count
    }

Use case

Allows getting the total number of records for pagination to display total number of records to users / Provide accurate "Showing X of Y results".

Database changes

No response

External dependencies

No response

Originally created by @patrickfnielsen on GitHub (Jun 19, 2025). ### NetBox version v4.3.2 ### Feature type Change to existing functionality ### Proposed functionality NetBox v4.3.0 introduced pagination in GraphQL. I would like to propose that we include support for a "metadata" object containing record counts, like there is in the rest api. It could look like this: ``` page_metdata { count } ``` ### Use case Allows getting the total number of records for pagination to display total number of records to users / Provide accurate "Showing X of Y results". ### Database changes _No response_ ### External dependencies _No response_
Author
Owner

@arthanson commented on GitHub (Jun 20, 2025):

This is actually referenced in the Strawberry docs as an optional way to present the information: https://strawberry.rocks/docs/guides/pagination/overview

@arthanson commented on GitHub (Jun 20, 2025): This is actually referenced in the Strawberry docs as an optional way to present the information: https://strawberry.rocks/docs/guides/pagination/overview
Author
Owner

@patrickfnielsen commented on GitHub (Jul 2, 2025):

@arthanson strawberry-django provides an generic way to implement it: https://strawberry.rocks/docs/django/guide/pagination

But as I read it, it would be a breaking change as items would be wrapped in a results container. I assume that is something you want to avoid? If so I'll can have a look into how an custom implementation might look

@patrickfnielsen commented on GitHub (Jul 2, 2025): @arthanson strawberry-django provides an generic way to implement it: https://strawberry.rocks/docs/django/guide/pagination But as I read it, it would be a breaking change as items would be wrapped in a `results` container. I assume that is something you want to avoid? If so I'll can have a look into how an custom implementation might look
Author
Owner

@jeremystretch commented on GitHub (Jul 16, 2025):

But as I read it, it would be a breaking change as items would be wrapped in a results container. I assume that is something you want to avoid?

Yes; we need to avoid any breaking changes to the GraphQL API in v4.4. Let's tag this for v4.5.0.

@jeremystretch commented on GitHub (Jul 16, 2025): > But as I read it, it would be a breaking change as items would be wrapped in a `results` container. I assume that is something you want to avoid? Yes; we need to avoid any breaking changes to the GraphQL API in v4.4. Let's tag this for v4.5.0.
Author
Owner

@tyler-8 commented on GitHub (Aug 30, 2025):

This is important for effective pagination usage. With a total count and a limit, you can pre-calculate the number of required pages. From what I can tell in the current implementation, you end up having to paginate until you get no results back - which leads to one more API call than is required and no way to know the size of the dataset through GraphQL.

@tyler-8 commented on GitHub (Aug 30, 2025): This is important for effective pagination usage. With a total count and a limit, you can pre-calculate the number of required pages. From what I can tell in the current implementation, you end up having to paginate until you get no results back - which leads to one more API call than is required and no way to know the size of the dataset through GraphQL.
Author
Owner

@patrickfnielsen commented on GitHub (Nov 19, 2025):

@arthanson I am curios as I see you created an implementation for the v2 api that was closed - Is that because v2 of the GraphQL API wont be in NetBox 4.5.0?

If that is the case I can understand it as it's a large breaking change for v1 - but if you are introducing a new version, now would be the perfect time for a large breaking change ?

@patrickfnielsen commented on GitHub (Nov 19, 2025): @arthanson I am curios as I see you created an implementation for the v2 api that was closed - Is that because v2 of the GraphQL API wont be in NetBox 4.5.0? If that is the case I can understand it as it's a large breaking change for v1 - but if you are introducing a new version, now would be the perfect time for a large breaking change ?
Author
Owner

@arthanson commented on GitHub (Nov 19, 2025):

@patrickfnielsen yes, it and v2 of the API were too much of a breaking change for 4.5. We will consider it for a later release.

@arthanson commented on GitHub (Nov 19, 2025): @patrickfnielsen yes, it and v2 of the API were too much of a breaking change for 4.5. We will consider it for a later release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11295