fix(rest): allow @patch update obj to be a Partial #1894
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This changes the type of the
obj
argument in@patch
endpoints fromModel
toPartial<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 test
passes on your machineI'm afraid the develop branch is currently failing for me with:
Conflicting definitions for 'express-serve-static-core'
packages/cli
were updatedexamples/*
were updated