Guys, If I have a Relation for example "User ->...
# orm-help
t
Guys, If I have a Relation for example "User -> Posts" - UserPosts. I know how to query this in graphql, but how do I query this in Java/Typesript? I can do "ctx.db.query.user ...." but how do I specify that I want posts ?
h
For paggination you need:
Copy code
users {
  post(first: 20) {
     title
  }
}
in info object of query
I would suggest you to read all parts 🙂
t
Hi, as I mentioned, I know how to do this in Graphql
But how to do this in javascript?
I need to call the code in my resolver
Thanks for your reply
In other words, how would you write a resolver for this?
I went through the article you mentioned, but exactly where I have a problem is an error: feed: (root, args, context, info) => { console.log(
Query.feed - info:
, JSON.stringify(info)) return posts } posts is nowhere defined .. ;(
h
Copy code
context.db.Users({},`{users{posts(first:20){name}}`)
something like this not sure for exact syntax
n
@Tomas did you set up a
prisma-binding
instance and added it to the
context
of your GraphQL server?
then you can run
ctx.db.query.users
for example, as @huv1k showed.
t
Thanks for your help guys. It works! A bit sad though, as I wanted it to be nicely type safe 😉 That's why I loved the object approach.
FYI, this one is correct: context.db.Users({},
{posts(first:20){name}
)
h
I think there is something on the way for make everything type safe 🙂
👀 1
🤫 1