Open Mirasaki opened 1 month ago
Can you try this before
hook in edit
in the resource that's edited?
import { Before } from 'adminjs';
const excludeIdPropertyFromPayload: Before = async (request, context) => {
if (request.method === 'get') {
return request;
}
const resource = context.resource.decorate();
const { payload = {} } = request;
const updatedPayload = {};
for (const key of Object.keys(payload)) {
const property = resource.getPropertyByKey(key);
if (!property || !property.isId()) {
updatedPayload[key] = payload[key];
}
}
request.payload = updatedPayload;
return request;
};
That addresses the issue, thanks. I'm not sure if I'm supposed to close this, though - as I reckon it's an internal bug. It only seems to happen when using @adminjs/relations
.
id
is being sent in the update requests, which is not an accepted property. Full stack trace below. I tried looking for an option to exclude this field from the payload throughproperties
, but wasn't able to find any relevant options.User Resource
User Model
Packages
Stack Trace