Hi guys, whats the easyiest way to query prisma fr...
# prisma-whats-new
m
Hi guys, whats the easyiest way to query prisma from the server with custom attributes such as
last
or
skip
? Example Query:
Copy code
const post = await ctx.db.query.posts(
        {
          where: {id: postId},
        },
        `{
         id
         text
       }`
      )
I would like to get only the last 10 posts for performance. Whats the way to go? (Sorry, Im really not getting the hang of where to find answers to these questions in the docs)
m
thx @nilan, that part of the docs I found 🙂. but how to include that in the typescript query method above exposed by prisma?
n
it's a similar to the
where
argument
Copy code
{
          where: {id: postId},
          last: 42
        },
m
Haha ok great thank you, I could have sworn I tried that 🙂, excuse me. A good sign that its been enough screen time today 🤒
🙌 1
n
no worries at all 🙂 would love to hear your thoughts on how to specifically improve the documentation, or even help you with a PR if you want to improve it yourself!
m
Ahhh, I have to correct myself though. The problem I am facing is a bit more complex, that explains my confusion with myself 🙂 The property that I am trying to limit with
last
is nested in a mutations return value, i.e.
Copy code
const res = await ctx.db.mutation.updateBlog({
      where: { id: blogId },
      data: {
        ...
      }
    },  `{
      id
      posts{
        id
      }
    }`)
I am trying to limit the number of posts returned from the mutation defined as a raw String. Is that possible?
n
Yes. One way to do it is to write a resolver for the type you're returning in your current resolver.
m
I am currently working on a project for a client, so currently there is time pressure involed 😞. As I really love the idea behind prisma, I will gladly contribute as soon as my schedule eases up a bit!
👌 1
n
I touched on a similar situation here: https://github.com/graphcool/prisma-binding/issues/61 If you have further questions about your specific case, please describe your situation in the forum: https://www.graph.cool/forum/c/questions
m
Perfect, thanks a mil!
n
absolutely 🙌