W
Wasp-langβ€’12mo ago
Dayne

Update return entity type

Didn't find this in the docs or through questions here.
I want typescript to respect the return type that has foreign relationships returned. For example, I have this query:
query getAllInventory {
fn: import { getAllInventory } from "@server/queries.js",
entities: [Inventory]
}
query getAllInventory {
fn: import { getAllInventory } from "@server/queries.js",
entities: [Inventory]
}
But it is selecting some related tables:
const inventory = await context.entities.Inventory.findMany({
where: {
userId: context.user?.id,
},
include: {
category: true,
subcategory: true,
store: true,
partner: true,
refund: true,
},
});
const inventory = await context.entities.Inventory.findMany({
where: {
userId: context.user?.id,
},
include: {
category: true,
subcategory: true,
store: true,
partner: true,
refund: true,
},
});
Is there a way to update it so that when I access this return type on the frontend I get typescript completion for the included tables? I can't seem to find a way to do this from the main.wasp file.
Thanks!!!
4 Replies
Filip
Filipβ€’12mo ago
Hey @Dayne, excellent question and sorry for the late reply. Happy Holidays btw! The short version is: Wasp does not yet support this in the cleanest imaginable way, but it's definitely possible! We'll have cleaner support in a couple of weeks! Since another one of our users asked the exact same question a couple of days ago, here's the thread: https://discord.com/channels/686873244791210014/1186410195732140073/1186410195732140073. I think you'll find your solution inside πŸ™‚ Let me know if you run into any kind of issue and I'll be glad to help you out!
Dayne
DayneOPβ€’11mo ago
Thanks! I went with option 1 you listed for now and that seems to work. I haven't attempted to deploy yet so unsure of hitting this issue This is also blocking me from successfully deploying to Fly.io that KYAN1TE mentioned. I will just cross that bridge when I get there. πŸ˜„
MEE6
MEE6β€’11mo ago
Wohooo @Dayne, you just became a Waspeteer level 2!
Filip
Filipβ€’11mo ago
Happy to help! There shouldn't be any issues during deployment, but let us know if there are πŸ™‚
Want results from more Discord servers?
Add your server