Hey, guys. How do we return relations in the new p...
# orm-help
x
Hey, guys. How do we return relations in the new prisma-client? It seems the
prisma.posts()
command will omit the
author: User!
field since it's a relation. Do I have to write my own fragment or another graphql query to send via
prisma.request
? This seems a little redudant, and I want to use what
prisma
has already generated.
w
I didnt try it myself but I think thats what you are looking for: https://www.prisma.io/docs/prisma-client/api-reference/reading-data-JAVASCRIPT-rsc2/#relations
x
Hey, @w0wka91 thanks for the reply. But that only returns for instance author of the post. I would like
prisma.posts
to return all the field in the
posts
including
author
so in the frontend I can write query like
{ posts { author { name } } }
. I just realize it's essentially the discussion here https://www.prisma.io/forum/t/help-understanding-prisma-clients-value-proposition/4394. I wonder if I have to go back to prisma-bindings.
w
Sorry, i can't help you with that. There's currently alot of confusion around the new prisma client tho
n
Hey @Xiaoyun Yang, the forum thread you linked to turned into a general and broad discussion. Could you please create a new forum post specifically about your situation, so we can help you with that as soon as possible? 🙂