hinsxd
10/05/2018, 5:26 AMdivyendu
10/05/2018, 5:52 AMschema delegation then bindings is the way to go. Otherwise, client is the way to go.
This discussion will help you make the decision better -> https://www.prisma.io/forum/t/help-understanding-prisma-clients-value-proposition/4394/17?u=divyendu_singh
We are working on making the docs more consistent and better!hinsxd
10/05/2018, 6:18 AMinfo is need, while Client provides a simpler and more intuitive API like "getting a property from big object". Is my understanding close enough?
But when my schema has a few layers of relations with interfaces and query fragments, I already found it difficult to implement the resolvers. In such case, I should keep using binding, am I correct? Thanks again!nikolasburk
info object. If you feel comfortable with using Prisma bindings, there's no need to move away from that!hinsxd
10/05/2018, 8:20 AMtype Query {
fooUsers: [User!]!
barUsers: [User!]!
}
interface User {
name: String!
}
type FooUser implements User {
name: String!
foo: [Foo!]!
}
type BarUser implements User {
name: String!
bar: [Bar!]!
}
when I query with prisma-binding, I have to implement custom resolvers for FooUser.foo and BarUser.bar. If I want to use the client, despite needing to implement resolvers for all fields, can I retrieve fooUser.foo directly with foo: parent => parent.foo() in FooUser.js?hinsxd
10/05/2018, 12:27 PM.field() to let prisma do the delegation for you.
Yes this is indeed resolver mania, but this seems to be so easy to write a tool for this!divyendu
10/06/2018, 3:58 AMhinsxd
10/06/2018, 8:09 PMfooUsers{
name
... on FooUser {
foo {
someValues
}
}
}
the default resolvers with prisma-binding could not return foo. I had to implement the FooUser resolver (suppose every object has a unique ID and it is always queried) like:
foo: (fooUser, _, { db }, __) =>
db.query
.user({ where: { id: fooUser.id } }, `{ name foo { someValues } }`)
.then(( { foo } ) => foo)
But now with prisma-client, it seems to be more straightforward that it becomes
foo: ({ id }, _ , { prisma }, __) => prisma.user({ id }).foo()
Although I have to do this for every fields, they look exactly the same if I don't implement any logic. That's why I think it would be easy to write a generator for this.