Hey folks. Let’s say I an using the enw prisma-cli...
# orm-help
j
Hey folks. Let’s say I an using the enw prisma-client, and have a resolverMap like so:
Copy code
Query: {
    async cart(obj, args, context, info) {
      const { user_id } = await getUserFromAuthorizationHeader(
        context.authorization
      );
      const cart = await prisma.portalCart({owner: user_id});
      return cart;
    }
  }
}
Cart: {   
  async items(obj, args, context, info) {
      const items = await prisma.portalCart({ owner: obj.owner }).items();
      return items;
   }
}
is that
await prisma.portalCart({ owner: obj.owner }).items()
using a cached version of portalCart, or is it having to fetch it again? If so, Is there a way to get both the cart AND it’s items? What I am trying to avoid is having to do two different queries for prisma.cart() if I can avoid it.
h
First, the
Cart:
type should be placed outside/along with
Query
. What client are you using? For example in Apollo Client, what is your
fetchPolicy
? Unfortunately you have to implement resolver and use prisma for every non-scalar fields, AFAIK.
j
Cart being in there was a typo, fixed. As for fetch policy, it’s the default
cache-first