Closed beeb closed 1 year ago
I'm 99% sure this is just a naming conflict. All Data
structs get a Specta rename to their model name and I'm not changing that, picking a different name for your custom Settings
struct should fix it.
Perhaps I could add an option for customisation of the name such as adding a prefix or even a transformer function in the CLI, but I'm not changing the default behaviour.
You were right! Name conflict, when I changed my struct to AppSettings
, an additional binding was created.
Might be worth thinking about documenting this or maybe printing our a warning if such a situation is encountered (provided it can be detected).
Thanks for the help!
The next rspc release will have proper errors for duplicate type names. Sorry for the confusion with it!
Consider the following prisma schema:
The generated
PrismaClient
shows the following:I setup a query and mutation as follows in the rspc router (note that the mutation doesn't return the same type as the query):
I expect the return value to be the same shape as
Data
above, but here is what rspc generates in TS-land in the end:So when in fact I get the following back from the rspc call in TS-land:
{key: "profile.some_setting", valueBool: null, /*...*/ valueString: "foobar"}
,TypeScript thinks I'm getting
{ profile: { some_setting: "foobar" } }
I think the problem might stem from the following rename generated in
prisma.rs
:The
Data
struct below this statement is not equivalent toSettings
which is my custom struct with aprofile
member. It seems rspc never generates a binding for theData
struct and also uses the wrong type for the return value of the mutation.