Skip to content

Calling paginate manually and enforce a Cursor Page #840

Answered by uriyyo
maciossek asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @maciossek,

You should also call set_page if you use paginate outside the route:

from fastapi_pagination import set_page

def get_viewer_catalogue_items(root: "Viewer", info: Info[Context, "Viewer"]) -> LimitCursorPage500[ProductResponse]:
    cursor = CursorParams()
    set_page(LimitCursorPage500[ProductResponse])

    return paginate(info.context.db, select(Product).where(Product.userId == info.context.user.id).order_by(Product.id), cursor)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@maciossek
Comment options

Answer selected by maciossek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants