backpack1098B
Convex Community2y ago
1 reply
backpack1098

queryWithUser is not a function.

(not urgent)
hi team! im working on some unit tests. the convex-test library is awesome and fun! however, im running into a weird scenario (not related to the lib perhaps).
// users.ts
import { LIMIT } from "./usage"

export const createUser = mutation({
  ...
  await ctx.db.insert("usage", {
    userId,
    used: 0,
    limit: LIMIT,
  })

...

const addUser = customCtx(async (ctx: QueryCtx) => {
  const userId = await getUserIdByTokenIdentifier(ctx)
  if (!userId) {
    throw new ConvexError("User ID not found")
  }
  return { userId }
})

export const queryWithUser = customQuery(query, addUser)

and when i run vitest, im getting
TypeError: queryWithUser is not a function
 ❯ convex/usage.ts:24:25
     22| })
     23|
     24| export const getUsage = queryWithUser({
       |                         ^
     25|   handler: async (ctx) => {
     26|     const usage = await ctx.db

but when i hard code the LIMIT to be 100, it works. any idea what's wrong? 🙏
Was this page helpful?