keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Arrays returned from query api are not iterable.

Open GalStan opened this issue 3 years ago • 0 comments
trafficstars

If you try to query some array from db via query api you will get array with null as prototype.

const { roles } = await context.query.AuthUser.findOne({
  where: { id: item.authUserId as string },
  query: "roles { name }"
});

return Array.prototype.map.call(roles, role => role.name).join(", ");

roles there is a 'demilitarized' object so I have to use array prototype explicitly.

At the moment I found only this ugly workaround to sort it out. There is no such problem with prisma api.

GalStan avatar Jul 15 '22 10:07 GalStan