- SDK build failed with exit code: 2
Heyy @kapa.ai I need your wisdom here
[ Wasp ] ext-src/dashboard/exercises/ExerciseForm.tsx(22,58): error TS2345: Argument of type 'GetBodyParts' is not assignable to parameter of type 'Query<never, Payload>'.
[ Wasp ] Type 'GetBodyParts' is not assignable to type '(args?: unknown) => Promise<Payload>'.
[ Wasp ] Target signature provides too few arguments. Expected 2 or more, but got 1.
[ Wasp ] ext-src/dashboard/exercises/ExerciseForm.tsx(23,32): error TS2304: Cannot find name 'useAction'.
//@src/dashboard/bodyparts/BodyPartQueries.ts
import { GetBodyParts, GetBodyPartById } from 'wasp/server/operations';
export const getBodyParts: GetBodyParts = async (args, context) => {
return context.entities.BodyPart.findMany();
};
export const getBodyPartById: GetBodyPartById = async ({ id }, context) => {
const bodyPart = await context.entities.BodyPart.findUnique({
where: { id },
include: { exercises: true }
});
if (!bodyPart) {
throw new Error('BodyPart not found');
}
return bodyPart;
};
//@src/dashboard/exercises/ExerciseActions.ts
import { CreateExercise, UpdateExercise, DeleteExercise } from 'wasp/server/operations';
export const createExercise: CreateExercise = async ({ name, instructions, difficulty, equipmentRequired, equipment, bodyPartId }, context) => {
return context.entities.Exercise.create({
data: {
name,
instructions,
difficulty,
equipmentRequired,
equipment,
bodyPart: { connect: { id: bodyPartId } }
}
});
};
export const updateExercise: UpdateExercise = async ({ id, name, instructions, difficulty, equipmentRequired, equipment, bodyPartId }, context) => {
return context.entities.Exercise.update({
where: { id },
data: {
name,
instructions,
difficulty,
equipmentRequired,
equipment,
bodyPart: { connect: { id: bodyPartId } }
}
});
};
export const deleteExercise: DeleteExercise = async ({ id }, context) => {
const exercise = await context.entities.Exercise.findUnique({
where: { id }
});
if (!exercise) {
throw new Error('Exercise not found');
}
return context.entities.Exercise.delete({
where: { id }
});
};
What and where is going something wrong?36 Replies
Hi @NEROX. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the error messages you provided, it seems like there are two main issues:
1. The
GetBodyParts
query is not correctly defined or used. The error message suggests that it expects two arguments, but only one is provided. However, in the code you provided, GetBodyParts
only takes one argument. This discrepancy might be due to a mismatch between the definition and usage of GetBodyParts
. Make sure that the definition of GetBodyParts
in wasp/server/operations
matches its usage in your code.
2. The useAction
function is not found. This might be because it's not imported in the file where it's used. Make sure to import useAction
from the correct module.
Unfortunately, without more context or code, it's hard to provide a more specific solution. You might want to check the relevant parts of your code and ensure that all functions and types are correctly defined and imported. If the problem persists, consider asking for help in the Wasp community or opening an issue on the Wasp GitHub repository.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai What kind of my files/code will help you to understand better the problem?
Let me check the knowledge base for you. One moment! :books:
----------------------
To better understand the problem, it would be helpful to see the following:
1. The file where the
GetBodyParts
query is used. The error message suggests that it's used in ExerciseForm.tsx
, so the code from this file would be useful.
2. The definition of GetBodyParts
in wasp/server/operations
. This would help to understand what arguments GetBodyParts
expects and how it should be used.
3. The file where useAction
is used. The error message suggests that useAction
is not found, so it would be helpful to see the code where it's used to understand why it's not found.
4. Any other files that are relevant to the GetBodyParts
query and the useAction
function. This might include files where related queries or functions are defined or used.
Please make sure to remove or anonymize any sensitive information before sharing your code.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai
1. Useaction is only used in the form component, tell me if it is not necessary.
2. The
BodyPartQueries.ts
:
import { GetBodyParts, GetBodyPartById } from 'wasp/server/operations';
export const getBodyParts: GetBodyParts = async (args, context) => {
return context.entities.BodyPart.findMany();
};
export const getBodyPartById: GetBodyPartById = async ({ id }, context) => {
const bodyPart = await context.entities.BodyPart.findUnique({
where: { id },
include: { exercises: true }
});
if (!bodyPart) {
throw new Error('BodyPart not found');
}
return bodyPart;
};
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on the code you've provided, it seems like the
GetBodyParts
and GetBodyPartById
queries are correctly defined in BodyPartQueries.ts
. They are both asynchronous functions that interact with the BodyPart
entity in the context.
As for the useAction
hook, it's a feature provided by Wasp that allows you to enhance actions with additional behavior, such as optimistic updates. However, it's not strictly necessary to use useAction
to use actions in Wasp. Actions can be called directly without wrapping them in a hook, as they don't require reactivity. If you're not using any of the additional features provided by useAction
, you might not need to use it in your form component.
However, without seeing the code of your form component, it's hard to say for sure whether useAction
is necessary or not. If you're still unsure, you might want to refer to the Wasp documentation on actions (https://wasp-lang.dev/docs/data-model/operations/actions) for more information.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai
I have reduced the number of errors :D
What do you think could be causing this?
What code would give you context to understand the problem and find the solution?
[ Wasp ] ext-src/dashboard/exercises/ExerciseForm.tsx(23,58): error TS2345: Argument of type 'GetBodyParts' is not assignable to parameter of type 'Query<never, Payload>'.
[ Wasp ] Type 'GetBodyParts' is not assignable to type '(args?: unknown) => Promise<Payload>'.
[ Wasp ] Target signature provides too few arguments. Expected 2 or more, but got 1.
[ Wasp ] ext-src/dashboard/exercises/ExerciseForm.tsx(149,36): error TS2304: Cannot find name 'CreateExercise'.
Let me check the knowledge base for you. One moment! :books:
----------------------
The error messages suggest two issues:
1. The
GetBodyParts
query is not correctly used. The error message indicates that it expects two arguments, but only one is provided. However, in the code you provided earlier, GetBodyParts
only takes one argument. This discrepancy might be due to a mismatch between the definition and usage of GetBodyParts
. Make sure that the definition of GetBodyParts
in wasp/server/operations
matches its usage in your code.
2. The CreateExercise
function is not found. This might be because it's not imported in the file where it's used. Make sure to import CreateExercise
from the correct module.
To better understand the problem, it would be helpful to see the following:
- The file where the GetBodyParts
query and CreateExercise
function are used. The error message suggests that they're used in ExerciseForm.tsx
, so the code from this file would be useful.
- The definition of GetBodyParts
and CreateExercise
in wasp/server/operations
. This would help to understand what arguments they expect and how they should be used.
Please make sure to remove or anonymize any sensitive information before sharing your code.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai
I have an
BodyPartsList.tsx
component, that displays all body parts with their descriptions:
import { BodyPart } from 'wasp/entities';
import { deleteBodyPart } from 'wasp/client/operations';
//....more core here.......
<TableBody>
{bodyParts.map((bodyPart) => (
<TableRow key={bodyPart.id} className="hover:bg-gray-100 dark:hover:bg-gray-700">
<TableCell className="text-gray-900 dark:text-white text-sm py-3">
{bodyPart.name}
</TableCell>
<TableCell className="text-gray-900 dark:text-white text-sm py-3">
{bodyPart.description || 'No description'}
</TableCell>
//....more core here.......
Is something relevant for you? because its using the Description alsoLet me check the knowledge base for you. One moment! :books:
----------------------
The
BodyPartsList.tsx
component you've shared is indeed relevant as it provides context on how you're using the BodyPart
entity and the deleteBodyPart
operation in your application. However, it doesn't seem to directly relate to the errors you're encountering.
The errors you're seeing are related to the GetBodyParts
query and the CreateExercise
function, which are not used in the BodyPartsList.tsx
component based on the code you've shared.
To resolve the errors, you'll need to ensure that the GetBodyParts
query and the CreateExercise
function are correctly defined and used in the relevant parts of your code. As mentioned earlier, it would be helpful to see the file where these are used (ExerciseForm.tsx
based on the error messages) and their definitions in wasp/server/operations
.
If you're still encountering issues, consider reaching out to the Wasp community or opening an issue on the Wasp GitHub repository for more specific help.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?ok will check that later
@kapa.ai If you had this in your
schema.prisma
:
model Exercise {
id Int @id @default(autoincrement())
name String
instructions String
difficulty Difficulty
equipmentRequired Boolean
equipment String?
bodyPart BodyPart @relation(fields: [bodyPartId], references: [id])
bodyPartId Int
routines Routine[]
}
model BodyPart {
id Int @id @default(autoincrement())
name String @unique
description String?
exercises Exercise[] // Relación uno-a-muchos con ejercicios
}
enum Difficulty {
EASY
MEDIUM
HARD
}
What would be an example query to get bodypart and also to get exercise? In the same way, what would be your actions? You have to give me an example of create, update and delete.Wohooo @NEROX, you just became a Waspeteer level 6!
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on the
schema.prisma
you've provided, here are examples of how you might define queries and actions for BodyPart
and Exercise
entities in Wasp:
Queries:
To fetch all body parts:
To fetch a specific exercise by id:
Actions:
To create a new exercise:
To update an existing exercise:
To delete an existing exercise:
These are just basic examples. Depending on your application's requirements, you might need to modify these queries and actions or add additional ones.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai
It's correct to manage the structure like this?
src
└── dashboard
├── bodyparts
│ ├── BodyPartActions.ts
│ ├── BodyPartQueries.ts
│ └── BodyPartsPage.tsx
└── exercises
├── ExerciseActions.ts
├── ExerciseQueries.ts
└── ExercisesPage.tsx
Let me check the knowledge base for you. One moment! :books:
----------------------
Yes, the structure you've proposed is a good way to organize your code. It's clear and modular, with each feature (body parts and exercises) having its own directory. Inside each feature directory, you have separate files for actions, queries, and the main page component, which makes it easy to find and manage the code related to each feature.
This structure aligns with the recommendation from the Wasp documentation (https://wasp-lang.dev/docs/tutorial/project-structure) to organize code by features (i.e., vertically). However, Wasp allows you to organize and structure your code however you think is best, so feel free to adjust this structure to suit your needs.
Also, remember that Wasp supports both JavaScript and TypeScript, so you can choose to use either or mix them as you see fit. The code examples you've provided are in TypeScript, but you could also write them in JavaScript if you prefer.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
@kapa.ai What will the BodyPartActions?
createBodyPart
updateBodyPart
deleteBodyPart
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on your
schema.prisma
and the structure you've proposed, here's how you might define createBodyPart
, updateBodyPart
, and deleteBodyPart
actions in BodyPartActions.ts
:
These are basic examples. Depending on your application's requirements, you might need to modify these actions or add additional ones.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai Thanks and for ExerciseActions.ts?
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on your
schema.prisma
and the structure you've proposed, here's how you might define createExercise
, updateExercise
, and deleteExercise
actions in ExerciseActions.ts
:
These are basic examples. Depending on your application's requirements, you might need to modify these actions or add additional ones.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai thanks, what will the correct code of BodyPartQueries.ts?
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on your
schema.prisma
and the structure you've proposed, here's how you might define getBodyParts
and getBodyPartById
queries in BodyPartQueries.ts
:
These are basic examples. Depending on your application's requirements, you might need to modify these queries or add additional ones.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai I just copied your code:
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(2,9): error TS1003: Identifier expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(2,42): error TS1128: Declaration or statement expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(2,44): error TS1434: Unexpected keyword or identifier.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(8,57): error TS1136: Property assignment expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(8,63): error TS1005: ',' expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(8,64): error TS1128: Declaration or statement expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(8,66): error TS1434: Unexpected keyword or identifier.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(8,73): error TS1128: Declaration or statement expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(8,75): error TS1128: Declaration or statement expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(9,64): error TS1136: Property assignment expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(10,13): error TS1136: Property assignment expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(10,19): error TS1005: ',' expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(10,20): error TS1128: Declaration or statement expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(12,4): error TS1128: Declaration or statement expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(12,5): error TS1128: Declaration or statement expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(19,1): error TS1128: Declaration or statement expected.
[ Wasp ] ext-src/dashboard/bodyparts/BodyPartQueries.ts(19,2): error TS1128: Declaration or statement expected.
What did you broke?Let me check the knowledge base for you. One moment! :books:
----------------------
I apologize for the confusion. The error messages suggest that there are syntax errors in the
BodyPartQueries.ts
file. The GetBodyParts
and GetBodyPartById
imports are not actual functions provided by Wasp, they were used as placeholders in the example.
In Wasp, you define your own queries and actions. Here's how you might define getBodyParts
and getBodyPartById
queries:
These are basic examples. Depending on your application's requirements, you might need to modify these queries or add additional ones.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai but I have them in my
main.wasp
file, check this:
// BodyPart Operations
query getBodyParts {
fn: import { getBodyParts } from "@src/dashboard/bodyparts/BodyPartQueries",
entities: [BodyPart]
}
query getBodyPartById {
fn: import { getBodyPartById } from "@src/dashboard/bodyparts/BodyPartQueries",
entities: [BodyPart]
}
action createBodyPart {
fn: import { createBodyPart } from "@src/dashboard/bodyparts/BodyPartActions",
entities: [BodyPart]
}
action updateBodyPart {
fn: import { updateBodyPart } from "@src/dashboard/bodyparts/BodyPartActions",
entities: [BodyPart]
}
action deleteBodyPart {
fn: import { deleteBodyPart } from "@src/dashboard/bodyparts/BodyPartActions",
entities: [BodyPart]
}
Let me check the knowledge base for you. One moment! :books:
----------------------
The code you've shared from your
main.wasp
file correctly declares the queries and actions for the BodyPart
entity. These declarations tell Wasp where to find the implementation of each query and action (in the BodyPartQueries.ts
and BodyPartActions.ts
files, respectively), and which entity they're associated with (BodyPart
).
If you've implemented the queries and actions in BodyPartQueries.ts
and BodyPartActions.ts
as shown in the previous examples, and you're still encountering errors, the issue might be elsewhere in your code.
Here are a few things to check:
- Make sure the paths in the import
statements are correct. The paths should be relative to the src
directory, and the @src
alias can be used to reference this directory.
- Make sure the BodyPart
entity is correctly defined in your schema.prisma
file.
- If you're using TypeScript, make sure your types are correctly defined and used.
If you're still encountering issues, consider reaching out to the Wasp community or opening an issue on the Wasp GitHub repository for more specific help.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai how you will fetch all exercises? remember that they are also related with any bodypart
Let me check the knowledge base for you. One moment! :books:
----------------------
To fetch all exercises along with their associated body parts, you can define a query that uses Prisma's
findMany
method with the include
option. Here's an example:
This query will return all exercises from the database, and for each exercise, it will also fetch the associated body part.
Then, in your main.wasp
file, you would declare the getExercises
query like this:
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?You could use cursor or zed 👀
@kapa.ai
Based on this error:
[ Wasp ] ext-src/dashboard/exercises/ExerciseQueries.ts(1,10): error TS2395: Individual declarations in merged declaration 'getExercises' must be all exported or all local.
[ Wasp ] ext-src/dashboard/exercises/ExerciseQueries.ts(1,10): error TS2440: Import declaration conflicts with local declaration of 'getExercises'.
[ Wasp ] ext-src/dashboard/exercises/ExerciseQueries.ts(4,14): error TS2395: Individual declarations in merged declaration 'getExercises' must be all exported or all local.
What did you wrong here?:
// src/dashboard/exercises/ExerciseQueries.tsx
import { getExercises } from 'wasp/server/operations';
export const getExercises = async (args, context) => {
return context.entities.Exercise.findMany({
include: {
bodyPart: true
}
});
};
Let me check the knowledge base for you. One moment! :books:
----------------------
The error messages suggest that there's a naming conflict in your
ExerciseQueries.tsx
file. You're importing getExercises
from 'wasp/server/operations'
and then declaring a constant with the same name getExercises
.
The getExercises
you're trying to import from 'wasp/server/operations'
doesn't exist, which is likely causing the error. In Wasp, you define your own queries and actions, and there's no predefined getExercises
query to import.
Here's how you can correct your ExerciseQueries.tsx
file:
This code defines a getExercises
query that fetches all exercises from the database, including the associated body part for each exercise. You don't need to import getExercises
because you're defining it here.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Which of these two would you prefer for W10? I use VS Code
@kapa.ai but is in my
main.wasp
:
// Exercise Operations
query getExercises {
fn: import { getExercises } from "@src/dashboard/exercises/ExerciseQueries",
entities: [Exercise]
}
What's wrong here?Let me check the knowledge base for you. One moment! :books:
----------------------
The code you've shared from your
main.wasp
file is correct. It declares the getExercises
query and tells Wasp where to find its implementation (in the ExerciseQueries
file under the dashboard/exercises
directory).
The error you're encountering is not related to this declaration in main.wasp
, but to the ExerciseQueries.tsx
file. In the ExerciseQueries.tsx
file, you're trying to import getExercises
from 'wasp/server/operations'
, which is not necessary and is causing a naming conflict because you're also defining a getExercises
function in the same file.
To fix the error, you should remove the import statement from the ExerciseQueries.tsx
file. Here's how the corrected ExerciseQueries.tsx
file should look:
This code defines the getExercises
query, which fetches all exercises from the database, including the associated body part for each exercise. You don't need to import getExercises
because you're defining it in this file.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai
[ Wasp ] ext-src/dashboard/exercises/EditExerciseModal.tsx(3,30): error TS2305: Module '"wasp/entities"' has no exported member 'Difficulty'.
[ Wasp ] ext-src/dashboard/exercises/ExerciseForm.tsx(2,30): error TS2305: Module '"wasp/entities"' has no exported member 'Difficulty'.
schema.prisma:
enum Difficulty {
EASY
MEDIUM
HARD
}
Why?Let me check the knowledge base for you. One moment! :books:
----------------------
The error messages suggest that the
Difficulty
enum from your schema.prisma
file is not being correctly imported in your EditExerciseModal.tsx
and ExerciseForm.tsx
files.
In Wasp, Prisma enums are not directly exported as part of the wasp/entities
module. Instead, you can access the enum values through the Prisma client.
Here's an example of how you can import and use the Difficulty
enum in your ExerciseForm.tsx
file:
You would do the same in your EditExerciseModal.tsx
file.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai In both files, I imported Prisma from @prisma/client and defined Difficulty using Prisma.Difficulty. Then, I have updated references to Difficulty throughout the code to use this imported enum.
But:
[ Wasp ] ext-src/dashboard/exercises/EditExerciseModal.tsx(7,27): error TS2339: Property 'Difficulty' does not exist on type 'typeof Prisma'.
[ Wasp ] ext-src/dashboard/exercises/EditExerciseModal.tsx(20,55): error TS2694: Namespace '"/home/rootall/apps/minisaas-boilerplate/app/node_modules/.prisma/client/index".Prisma' has no exported member 'Difficulty'.
[ Wasp ] ext-src/dashboard/exercises/EditExerciseModal.tsx(93,75): error TS2694: Namespace '"/home/rootall/apps/minisaas-boilerplate/app/node_modules/.prisma/client/index".Prisma' has no exported member 'Difficulty'.
[ Wasp ] ext-src/dashboard/exercises/ExerciseForm.tsx(7,27): error TS2339: Property 'Difficulty' does not exist on type 'typeof Prisma'.
[ Wasp ] ext-src/dashboard/exercises/ExerciseForm.tsx(68,100): error TS2694: Namespace '"/home/rootall/apps/minisaas-boilerplate/app/node_modules/.prisma/client/index".Prisma' has no exported member 'Difficulty'.
Let me check the knowledge base for you. One moment! :books:
----------------------
I apologize for the confusion. The Prisma client does not directly export enums defined in your
schema.prisma
file. Instead, the enum values are available as properties on the model instances.
However, Wasp currently does not support Prisma enums directly. There is an open issue on the Wasp GitHub repository to add support for Prisma enums (#641 (https://github.com/wasp-lang/wasp/issues/641)).
As a workaround, you can define the Difficulty
enum in your TypeScript code and use it in your components:
Please note that this workaround requires you to manually keep the TypeScript enum in sync with the enum in your schema.prisma
file.
For more information on how to work with data in Wasp, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/data-model/overview).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?✅ Solved. You did it great ma boi kapa🤜 🤛 🥹