You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the logs show that the correct database queries are made to retrieve the model specified in the include directive from the DB.
However the related data is not present in the result-object, rather just the fields of basic types relationships. This is despite the relations being properly defined in the schema (i.e. the relationships work in Prisma studio). In particular I can do the following:
In the past, that is, before include and select was a feature, the returned type was that of the model generated from the Prisma schema, in this case Job. Now it is SerializeObject<UndefinedToOptional<Job>>. I do not know if this is related to the issue.
I may be doing something wrong, but another person is experiencing this as well, so it may be version-specific or perhaps the docs are hard to understand (or I am just bad at reading), but I tried numerous times to get it to work to no avail.
How to reproduce
Create bare-bones trpc-prisma-starter project using the setup guide and the dependencies listed in "Environment and Setup".
Generate the model.
Run a query with include.
If you let me know I can share the project in question, since it includes a lot of boilerplate.
I think we could integrate this "workaround" which gets the PayloadType by inferring the query parameters as said in #61
Maybe when enabling "include" the generator should add this inference. so that included or selected relational fields show up in the procedures return type. Definitely a pretty important thing to offer for typescript users.
I went into a little rabbithole.
I tried to get the Payload type with Prisma.TableGetPayload<typeof input> which does work when passing it to useQuery<myPayloadTyle> and infers my types when including in a predefined query input. Then I tried to add this to a generated FindFirst procedure but because at this scope it cannot infer the type given the input. It seems to me this is an intricate typescript inference story...
At this point I think it could only be done by some genetic payload wrapper type in the useQuery call to pass down the type of the query input directly to the Prisma call and back.
Bug description
Related data when using
include
in queries not available.When issuing a query, e.g.:
the logs show that the correct database queries are made to retrieve the model specified in the
include
directive from the DB.However the related data is not present in the result-object, rather just the fields of basic types relationships. This is despite the relations being properly defined in the schema (i.e. the relationships work in Prisma studio). In particular I can do the following:
while the following does not work:
In the past, that is, before
include
andselect
was a feature, the returned type was that of the model generated from the Prisma schema, in this caseJob
. Now it isSerializeObject<UndefinedToOptional<Job>>
. I do not know if this is related to the issue.I may be doing something wrong, but another person is experiencing this as well, so it may be version-specific or perhaps the docs are hard to understand (or I am just bad at reading), but I tried numerous times to get it to work to no avail.
How to reproduce
trpc-prisma-starter
project using the setup guide and the dependencies listed in "Environment and Setup".include
.If you let me know I can share the project in question, since it includes a lot of boilerplate.
Expected behavior
I expect that upon invoking the following query:
I should be able to do things like:
however the field is not present in the object.
Prisma information
Environment & setup
Using
package.yaml
:Prisma Version
The text was updated successfully, but these errors were encountered: