ThoorAdamT
Convex Community5mo ago
9 replies
ThoorAdam

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>'.


    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;


Everything seems to be working correctly though even with the error.
Was this page helpful?