kancur
kancur
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
Hey guys! I'm trying to use an action, imported like this:
import markTodoAsDone from '@wasp/actions/markTodoAsDone.js';
import markTodoAsDone from '@wasp/actions/markTodoAsDone.js';
inside a worker, defined inside server/workers/doSomething.ts The markTodoAsDone action seems to work fine on the client, but I'm not sure if I can use it inside a worker too? It seems it's missing a context.
Expected 2 arguments, but got 1.
An argument for 'context' was not provided.
Expected 2 arguments, but got 1.
An argument for 'context' was not provided.
Is this a natural limitation of how workers work? Or should I be able to use an action there as well? Thanks đŸ™‚
16 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
Hey guys! I'm following the docs on how to create a job (https://wasp-lang.dev/docs/advanced/jobs#job-definition-and-usage). Unfortunately, I'm having some type errors. I'm using openSaas template.
export const foo: MySpecialJob<Input, Output> = async ({ name }, context) => {
console.log(`Hello ${name}!`);
const tasks = await context.entities.Task.findMany({});
return { tasks };
};
export const foo: MySpecialJob<Input, Output> = async ({ name }, context) => {
console.log(`Hello ${name}!`);
const tasks = await context.entities.Task.findMany({});
return { tasks };
};
Error:
Type 'Output' does not satisfy the constraint 'void | JSONValue'.
Type 'Output' is not assignable to type 'JSONObject'.
Property 'tasks' is incompatible with index signature.
Type '(GetResult<{ id: string; description: string; time: string; isDone: boolean; userId: number; createdAt: Date; }, unknown> & {})[]' is not assignable to type 'JSONValue'.ts(2344)
Type 'Output' does not satisfy the constraint 'void | JSONValue'.
Type 'Output' is not assignable to type 'JSONObject'.
Property 'tasks' is incompatible with index signature.
Type '(GetResult<{ id: string; description: string; time: string; isDone: boolean; userId: number; createdAt: Date; }, unknown> & {})[]' is not assignable to type 'JSONValue'.ts(2344)
Is there some issue with the example that I missed? Thank you for your help!
26 replies