Search code examples
apostrophe-cms

apostrophe-headless PUT Requests override empty fields


I'm building an SPA with apostrophe-headless, Vue and Express as a proxy. What I'm trying to do is to update some fields, depending on what the user changed. To be more specific, I made a members module with several additional fields. Login works via Firebase (frontend) so I have a field with the userId to get a relation. But now, if I edit some fields and send it back to apostrophe, it updates all fields, also that ones I never sent. This is also overriding the userId field (not the _id field) if not permitted. The question:

Is it possible to just change the fields that I sent and furthermore, can I deactivate some fields for not being editable via REST-API? I would also be interested in hiding fields on the backend...

Thank you very much!


Solution

  • apostrophe-headless doesn't currently support a PATCH style request so you need to set your app up to have the entire doc (page or piece), modify it, and send the whole thing back to the API.