keystone
keystone copied to clipboard
Access denied on relationship fields connection
I am trying to connect images to my object with sudo context. Used the following code:
const context = req.KeystoneContext;
const localDb = context.sudo().db;
try {
await localDb.Motif.updateOne({
where: { sku: '027_DE' },
data: {
isImagesMigrated: true,
images: {
connect: [
{ id: 17674 },
{ id: 17675 },
{ id: 17676 },
{ id: 17677 },
{ id: 17678 }
]
}
}
});
}
catch (error) {
console.log(error);
console.log(error.extensions.debug);
}
And I see the following error:
GraphQLError: An error occured while resolving relationship fields.
- Motif.images: Access denied: You cannot connect that Image - it may not exist
I've tried to link it manually in admin panel then and it is all fine, so it looks like some bug there.
node: v16.20.1 keystone-6/core: v5.5.0
Updated:
Direct prisma
call works fine