Hi everybody! Nice to be here :slightly_smiling_fa...
# orm-help
m
Hi everybody! Nice to be here 🙂 I'm loving working with Prisma and have two questions: I've unfortunately been building my Prisma service in v.16 & .17 and now the new awesome prisma cool client is here. I'm heavily relying on the TS codegen and am a bit afraid to make the jump. - This link from the website is broken https://www.prisma.io/docs/maintain/upgrade-prisma/upgrade-to-1.8-jgp3 Does not give any helpful information in this regard. So my first question is: How do upgrade my Prisma service to use the client? I have a hard time finding any information about differences or anything really. 🙂 My second question is probably a lot easier to answer.. I'm making a query on my GraphQL Yoga server with bindings. But only some of the fields come back, when using the bindings.. The playground retrieves all the fields (which exists) just fine. But as soon as i make the query with the bindings
const order = await ctx.db.query.order({ where: { id } });
and log the result; all of the fields aren't retrieved. I'm baffled by this, there's no apparent explanation and of course no errors. So how do i retrieve all the fields from my type? And as an extra, why aren't they already retrieved? I'm sorry if this message is too long, furthermore I'd like to acknowledge my lack of technical information. I'd be happy to elaborate on anything. Anyways, have a nice day! ☀️
l
Welcome! I use both Prisma-Binding and Prisma Client concurrently. I use Binding for returning queried data and Client for everything else. Client provides a self-contained object that can be used outside of GraphQL -- that's its main benefit. So don't think of it as an upgrade. I think of it as another, more friendly API to make server to Prisma queries. You can put Prisma Client into your context along side the binding. Your query will only retrieve the scalar fields on the node -- that is, the data that resolves to a primitive, e.g.
string
. It will not get the relational data. To get the queried relational data, you need to pass the info object, e.g.
const order = await ctx.db.query.order({ where: { id } }, info);
I recommend reading and rereading the following blog post daily, as I have done. 🙂 https://www.prisma.io/blog/graphql-server-basics-demystifying-the-info-argument-in-graphql-resolvers-6f26249f613a/
m
Sorry for the late answer! Thank you very much for the info 🙂 I'll solve my problems in no time now! 😄