ThoorAdam
ThoorAdam3d ago

Paginated query type error

Getting the following error from my paginated query
Argument of type 'FunctionReference<"query", "public", { checklistId: Id<"checklists">; paginationOpts: { id?: number | undefined; endCursor?: string | null | undefined; maximumRowsRead?: number | undefined; maximumBytesRead?: number | undefined; numItems: number; cursor: string | null; }; }, PaginationResult<...> | null, string | un...' is not assignable to parameter of type 'PaginatedQueryReference'.
Types of property '_returnType' are incompatible.
Type 'PaginationResult<{ _id: Id<"checklistItems">; _creationTime: number; checklistId: Id<"checklists">; text: string; completed: boolean; }> | null' is not assignable to type 'PaginationResult<any>'.
Type 'null' is not assignable to type 'PaginationResult<any>'.
Argument of type 'FunctionReference<"query", "public", { checklistId: Id<"checklists">; paginationOpts: { id?: number | undefined; endCursor?: string | null | undefined; maximumRowsRead?: number | undefined; maximumBytesRead?: number | undefined; numItems: number; cursor: string | null; }; }, PaginationResult<...> | null, string | un...' is not assignable to parameter of type 'PaginatedQueryReference'.
Types of property '_returnType' are incompatible.
Type 'PaginationResult<{ _id: Id<"checklistItems">; _creationTime: number; checklistId: Id<"checklists">; text: string; completed: boolean; }> | null' is not assignable to type 'PaginationResult<any>'.
Type 'null' is not assignable to type 'PaginationResult<any>'.
const completedChecklistItems = usePaginatedQuery(
api.checklists.getCompletedChecklistItemsByChecklistId,
activeTab === 1 || hasActivatedCompletedTab ? { checklistId: checklistId as Id<'checklists'> } : 'skip',
{
initialNumItems: 25,
},
);
const completedChecklistItems = usePaginatedQuery(
api.checklists.getCompletedChecklistItemsByChecklistId,
activeTab === 1 || hasActivatedCompletedTab ? { checklistId: checklistId as Id<'checklists'> } : 'skip',
{
initialNumItems: 25,
},
);
const items = await ctx.db
.query('checklistItems')
.withIndex('checklistId', (q) => q.eq('checklistId', args.checklistId))
.filter((q) => q.eq(q.field('completed'), true))
.paginate(args.paginationOpts);

return items;
const items = await ctx.db
.query('checklistItems')
.withIndex('checklistId', (q) => q.eq('checklistId', args.checklistId))
.filter((q) => q.eq(q.field('completed'), true))
.paginate(args.paginationOpts);

return items;
Everything seems to be working correctly though even with the error.
2 Replies
Convex Bot
Convex Bot3d ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
ampp
ampp3d ago
I think its because your filter could cause it to return null. which blows up paginate some people filter null results first i can think of 5 ways to fix it.

Did you find this page helpful?