Nuno
Nuno
WWasp
Created by Nuno on 2/6/2025 in #đŸ™‹questions
OpenSaaS serverside actions/queries problem
Hi, I am using wasp version 0.16.0 and the openSaaS tempalte on linux and I am experiencing some troubles using queries/actions on the server side. To reproduce: -create a new folder in src (let say /error. -make @src/error/queries.js file with this code;
const tasks = [
{ id: 1, description: 'Buy some eggs', isDone: true },
{ id: 2, description: 'Make an omelette', isDone: false },
{ id: 3, description: 'Eat breakfast', isDone: false },
]
export const getAllTasks = () => {
return tasks
}
const tasks = [
{ id: 1, description: 'Buy some eggs', isDone: true },
{ id: 2, description: 'Make an omelette', isDone: false },
{ id: 3, description: 'Eat breakfast', isDone: false },
]
export const getAllTasks = () => {
return tasks
}
-create another file; @src/error/queries2.js with this code:
import { getAllTasks } from "wasp/server/operations";

// The 'args' object is something sent by the caller (most often from the client)
export const getFilteredTasks = async (args) => {
const { isDone } = args;

// Fetch all tasks using getAllTasks
const allTasks = await getAllTasks();

// Filter the tasks
return allTasks.filter((task) => task.isDone === isDone);
};
import { getAllTasks } from "wasp/server/operations";

// The 'args' object is something sent by the caller (most often from the client)
export const getFilteredTasks = async (args) => {
const { isDone } = args;

// Fetch all tasks using getAllTasks
const allTasks = await getAllTasks();

// Filter the tasks
return allTasks.filter((task) => task.isDone === isDone);
};
Define the queries in the main.wasp file;
query getAllTasks {
fn: import { getAllTasks } from "@src/error/queries.js"
}

query getFilteredTasks {
fn: import { getFilteredTasks } from "@src/error/queries2.js"
}
query getAllTasks {
fn: import { getAllTasks } from "@src/error/queries.js"
}

query getFilteredTasks {
fn: import { getFilteredTasks } from "@src/error/queries2.js"
}
Now it throws an error: [ Server!] code: 'ERR_MODULE_NOT_FOUND', [ Server!] url: 'file:///home/nuno120/Documents/BELLEN-AIPERSONAL/test2/app/.wasp/out/sdk/wasp/dist/ext-src/payment/plans' [ Server!] } [ Server!] Node.js v20.17.0 [ Server ] [nodemon] app crashed - waiting for file changes before starting... When i change the import of the task in queries2.js to this: import { getAllTasks } from "wasp/ext-src/error/queries"; it works again btw! But not with the wasp/server/operations. Anyone knows why/how to fix? Also I don't understand why it throws an error in the payment/plants file and it get's fixed when I change the import in another file....
19 replies