Jacob KimJ
Convex Community9mo ago
2 replies
Jacob Kim

how do I do optimistic update with a paginated query?

let's say api.queries.foobar is a paginated query. how can I perform an optimistic mutation witt that query?

Here is a sample code.
export function useMutation() {
  const mutationFn = useConvexMutation(api.queries.foobar).withOptimisticUpdate((localStore, args) => {
    const list = localStore.getQuery(api.queries.foobar, { paginationOpts: { numItems: 10 }})
    // TODO
  })
  return useMutation({ mutationFn })
}

I am not sure how I can fill in the paginationOpts of the query.
Was this page helpful?