Right.
But, that’s not strictly the Graphql API though that’s our python SDK Client. Apologies, I should have twigged that is what your frame of reference was.
Specifically, that resource interface doesn’t support using a cursor for pagination. It probably could/should.
In the meantime, you can craft something yourself.
Inspecting the code inside the SDK method:
commits = client.commit.list(wrapper.stream_id)
uses this query
query Commits($stream_id: String!, $limit: Int!) {
stream(id: $stream_id) {
commits(limit: $limit) {
items {
id
message
referencedObject
authorName
authorId
authorName
authorAvatar
branchName
createdAt
sourceApplication
totalChildrenCount
parents
}
}
}
}
we can amend the query and then wrap it in a new function (I’m making the response request briefer just for example):
query PaginatedCommits($stream_id: String!, $limit: Int!, $cursor: String) {
stream(id: $stream_id) {
commits(limit: $limit, cursor: $cursor) {
cursor
items {
id
message
referencedObject
}
}
}
}
The function is pretty simple:
from gql import gql
def get_paginated_commits(stream_id, limit, cursor):
query = gql(
"""
query PaginatedCommits($stream_id: String!, $limit: Int!, $cursor: String) {
stream(id: $stream_id) {
commits(limit: $limit, cursor: $cursor) {
cursor
items {
id
message
referencedObject
}
}
}
}
"""
)
params = {"stream_id": stream_id, "limit": limit, "cursor": cursor}
response = client.server.make_request(query=query, params=params, return_type=[])
return (
response["stream"]["commits"]["cursor"],
response["stream"]["commits"]["items"],
)
stream_id = wrapper.stream_id
limit = 3
cursor = ""
cursor, commits = get_paginated_commits(stream_id, limit, cursor)
'2023-09-12T17:30:24.232Z'
[{'id': '528d915022',
'message': 'Sent 18 elements from Navisworks.',
'referencedObject': 'f5d040c732c92869e93f710df29196d3'},
{'id': '0105cde21b',
'message': 'Sent 18 elements from Navisworks.',
'referencedObject': 'f5d040c732c92869e93f710df29196d3'},
{'id': '0e2d07497d',
'message': 'Sent 4 elements from Navisworks.',
'referencedObject': '53ec42b5f6e6f70d77b0eb0f59cf8d84'}]
and then calling that function again
'2023-09-12T17:30:24.232Z'
[{'id': 'd08855adb0',
'message': 'Sent 18 elements from Navisworks.',
'referencedObject': '24e46827fdc2fb783b1fac2684fb8b44'},
{'id': '715636467d',
'message': 'Sent 18 elements from Navisworks.',
'referencedObject': '30726c32e80251e74a0c7b11674d233c'},
{'id': 'aaaf0a9789',
'message': 'Sent 18 elements from Navisworks.',
'referencedObject': '293c8f60f220ce1d2c84d9b5ea755b1c'}]