nakajimayoshiN
Convex Community6mo ago
2 replies
nakajimayoshi

customQuery + type errors

is this supposed to happen when definiting custom functions? I have a separate file I want all my other mutations/queries to use to check auth before every request, but the moment I try exporting the custom function variable, convex throws a type error:
export const userQuery = customQuery(query, { // ERROR: <-- 'userQuery' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. (ts 7022)
  args: {},
  input: async (ctx, args) => {

    const db = wrapDatabaseReader(ctx, ctx.db, await rlsRules(ctx));
    return {
      ctx: { db },
      args: {},
      onSuccess: ({ args, result }) => { },
    };
  },
});

const userQuery = customQuery(query, { // No error, but now I can't use it in my other files..
  args: {},
  input: async (ctx, args) => {

    const db = wrapDatabaseReader(ctx, ctx.db, await rlsRules(ctx));
    return {
      ctx: { db },
      args: {},
      onSuccess: ({ args, result }) => { },
    };
  },
});
Was this page helpful?