fix(rest): allow @patch update obj to be a Partial#1894
fix(rest): allow @patch update obj to be a Partial#1894joeytwiddle wants to merge 2 commits intoloopbackio:masterfrom
Conversation
|
@joeytwiddle thank you for opening this pull request. The proposed changes are going in the right direction, but I am don't think we have the required underlying block already in place. - @requestBody() data: Todo,
+ @requestBody() data: Partial<Todo>,The way how When you change the type from If my description above still holds, then we need to find a way how to explicitly tell Would you like to take a look at this underlying feature first? |
I can confirm - |
|
I am closing this pull request as abandoned, feel free to reopen if you get time to work on this again. |
This changes the type of the
objargument in@patchendpoints fromModeltoPartial<Model>.Since the route checking has become more strict, requests to patch only some fields of a document are now being rejected, because the validation expects to see all required fields in the patch.
In our codebase, we have made the type of the update object
Partial<Model>to allow partial updates, and that has been working well.This is only a quick fix. I believe you may settle on a more comprehensive solution later, as discussed in #1722
Partial<Model>because I thought that was more appropriate thanDeepPartial<Model>orDataObject<Model>but I could be wrong.If this PR is not a step in the desired direction, then please feel free to close it.
Checklist
npm testpasses on your machineI'm afraid the develop branch is currently failing for me with:
Conflicting definitions for 'express-serve-static-core'packages/cliwere updatedexamples/*were updated