Need to pass resolveFields to lists.Product.findOne to return product.name
Hallvig opened this issue · comments
David Hallvig commented
In https://github.com/wesbos/advanced-react-rerecord/blob/master/finished-files/backend/schemas/CartItem.ts, for lists.Product.findOne()
to return not only { id }
but { id, name }
you need to pass resolveFields: 'id, name'
, as so:
let product = await lists.Product.findOne({
where: { id: String(cartItem.product) },
resolveFields: 'id, name'
});
if (product?.name) {
(I just found out by fooling around with Keystone-next, and the code currently never returns product.name
, only product.id
).
Really looking forward to the course, you're the best!
Wes Bos commented
thanks! I acutally ran into this in the recording - it was recently added