danlucraft
11/20/2018, 3:43 PMconst posts = await ctx.prisma.posts(null, " { id } ")
And here’s the corresponding log from prisma client lib:
Query:
{
posts {
id
title
url
}
}
Why…. does the logged query have title
and url
in when I’m specifying only "{ id }"
in my query call?nikolasburk
Post
type. With the Prisma client, this is possible via the $fragment
API, with Prisma bindings it should be possible using the same API call that you're showing here.nikolasburk
Whenever a model is queried using the Prisma client, all scalar fields of that model are fetched. This is true no matter if a single object or a list of objects is queried.https://www.prisma.io/docs/prisma-client/basic-data-access/reading-data-JAVASCRIPT-rsc2
nikolasburk
$fragment
API is explained here: https://www.prisma.io/docs/prisma-client/basic-data-access/reading-data-JAVASCRIPT-rsc2/#using-fragments-for-fine-grained-data-accessdanlucraft
11/20/2018, 3:51 PMdanlucraft
11/20/2018, 4:05 PMnikolasburk
danlucraft
11/20/2018, 4:07 PM