David AlonsoD
Convex Community2y ago
13 replies
David Alonso

Custom functions <> return validators

If I have something like this:
export const authenticatedQuery = customQuery(
  queryRaw, // The base function we're extending
  {
    args: {
      clerkOrgId: v.optional(v.string()),
    },
    input: async (ctx, args) => {
      const { user, workspace, role } = await enhanceAuthenticatedContext(
        ctx,
        args.clerkOrgId
      );

      return { ctx: { user, workspace, role }, args: {} };
    },
  }
);

How do I update it so that I don't get errors when doing this:
export const query = authenticatedQuery({
  args: {
...
  },
  returns: someValidator,
...
Was this page helpful?