CJCC
Convex Communityβ€’2y agoβ€’
2 replies
CJC

ArgumentValidationError

I'm getting the following error

ArgumentValidationError: Object is missing the required field `userId`. Consider wrapping the field validator in `v.optional(...)` if this is expected.

Object: {}
Validator: v.object({userId: v.id("users")})


However I'm confused if this is refering to the handler or the schema itself.

My handler looks like this which has the optional wrapped around the arg

export const get = query({
    args: {
        userId: v.optional(v.id('users')),
    },
    handler: async (ctx, args) => {
        if (args.userId === undefined) {
            return [];
        }
        return await ctx.table('tableName').filter((q) => q.eq(q.field('userId'), args.userId));
    },
});
Was this page helpful?