Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.8k stars 104 forks source link

Named Specta types in select! and include! - Feature Request #216

Closed JK2Kgit closed 1 year ago

JK2Kgit commented 1 year ago

While using named select and include bindings.ts still generate inline type instead of reference one which leads to less readable/ mockable types.

I suggest that when there is type name provided to select! or include! macro we should use it for generating specta reference type instead of inline type.

Brendonovich commented 1 year ago

Interesting idea but I'm not sure I'm onboard. At Spacedrive we've found that defining component prop types in a way that is decoupled from selection types is more flexible and a better dx, but I'm curious what your use case is?

Brendonovich commented 1 year ago

am gonna just implement this since it's not that hard and doesn't really change much actually this might be tricky, we'll see how it goes

JK2Kgit commented 1 year ago

Hi i Noticed update now My friend (who is responsible for front-end) complained that he needs to copy types for mocking and to functions or alias them outside of file. Mostly dx. Happy to see it done thanks.

Brendonovich commented 1 year ago

I assume you're talking about Erudio, so I checked how you're doing tests and noticed that you're mocking rspc responses. That makes sense, but rather than pass in the types to getData manually I'd suggest using rspc's inferProcedureResult helpers. That way you wouldn't need to use the generated types for include/select, and could also be a lot more certain about the data your tests need.