perf(client): pass pagination offset and limit as GraphQL variables#1207
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## infrahub-develop #1207 +/- ##
====================================================
- Coverage 83.98% 83.17% -0.81%
====================================================
Files 139 139
Lines 14390 12441 -1949
Branches 2381 1852 -529
====================================================
- Hits 12085 10348 -1737
+ Misses 1654 1528 -126
+ Partials 651 565 -86
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 13 files with indirect coverage changes 🚀 New features to boost your workflow:
|
dgarros
approved these changes
Jul 23, 2026
dgarros
left a comment
Contributor
There was a problem hiding this comment.
Looks good, ideally I think we should target infrahub-develop directly because there are a lot of changes in this branch right now compared to develop
Queries generated by all()/filters()/get() and the resource pool allocation lookup previously inlined offset and limit into the query text, so every page of a paginated fetch produced a different GraphQL document and could never hit the server-side query cache. Pagination now travels as $offset/$limit variables: the document stays identical across pages, and the query is rendered once per call instead of once per page. generate_query_data() and generate_query_data_init() accept variable placeholder strings (e.g. "$offset") for offset and limit, matching the existing $pool_id convention. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fatih-acar
force-pushed
the
fac/check-sdk-variables-2h509
branch
from
July 23, 2026 10:31
d9f39fd to
ac9e0f7
Compare
Deploying infrahub-sdk-python with
|
| Latest commit: |
ac9e0f7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://86441eb7.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://fac-check-sdk-variables-2h50.infrahub-sdk-python.pages.dev |
fatih-acar
marked this pull request as ready for review
July 23, 2026 11:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Paginated queries generated by the SDK (
all(),filters(),get(), and resource pool allocation lookups) now passoffsetandlimitas GraphQL variables instead of inlining them into the query text. The query document stays byte-identical across pages, so repeated pages of the same fetch can hit Infrahub's server-side GraphQL query cache (opsmill/infrahub#8102) — the same optimization the frontend adopted in opsmill/infrahub#8245.Key Changes
client.filters()(async and sync) renders the query once per call with$offset/$limitplaceholders and sends the per-page values in the GraphQLvariablespayload — previously the query was re-generated and re-rendered for every page with literal values baked in.get_pool_allocated_resources()(async and sync) does the same for its pagination loop, extending the$pool_id/$resource_idvariables it already used.generate_query_data()/generate_query_data_init()accept variable placeholder strings (e.g."$offset") foroffsetandlimit; passing literal ints keeps working unchanged.count()needed no change: it takes no pagination arguments, so its query text was already stable per filter set.Related Context
Documentation Updates
docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx) for the widened signatures.changelog/+graphql-pagination-variables.changed.md.Test Plan
uv run pytest tests/unit/— updated the six operation-name assertions to expect the($offset: Int!, $limit: Int!)signature; addedtest_method_all_pagination_uses_graphql_variables, which fetches two pages and asserts the query text is identical across pages while only the variables differ ({"offset": 0, "limit": 3}→{"offset": 3, "limit": 3}).uv run invoke lint-code(ruff, ty, mypy) passes;uv run invoke docs-generateoutput is committed.🤖 Generated with Claude Code
Summary by cubic
SDK paginated queries now send
offsetandlimitas GraphQL variables, keeping the query text identical across pages and enabling server-side cache hits. Queries are rendered once per call, andgenerate_query_data*now accept variable placeholders.offset/limitinall(),filters(),get(), and pool allocation lookups. One rendered document per call; per-page values go invariables.generate_query_data()andgenerate_query_data_init()acceptintor variable placeholders (e.g."$offset","$limit"). Backward compatible.count()unchanged.Written for commit ac9e0f7. Summary will update on new commits.