#Can internal query be recursive?

3 messages · Page 1 of 1 (latest)

glad barn
#

It doesn't seem like it but just double checking

cold linden
#

The handler can be recursive.

function qHandler(ctx, args) {
  // do some stuff
  qHandler(ctx, args);
   // more stuff
}

export const foo = internalQuery({args: {...}, handler: qHandler });
cold linden
#

calling the query itself recursively involves overhead for argument validation and making it into a transaction, so I wouldn't recommend it even if it were possible. Making the handler recursive or calling a recursive function from the query is usually better