RFC: support for updating a contact #86
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Updating a contact may be considered a fairly basic feature that should probably be implemented. However, it is not as straight forward as one might think.
If you are in need of this functionality, please +1 this post by means of a GitHub reaction (so not with a comment).
Approach 1
The easiest approach would be to implement a PUT instead of PATCH (REST-API analogy). That means that the contact will get completely overwritten with the newly defined values. Essentially, this would be the same as removing the contact and creating a new one.
This is quite easy to implement, but the developer experience, and (maybe moreover) the user experience is sub-optimal to say the least.
If the developer only wants to update a single contact's phone number, he would still have to retrieve all of that user's data, and consequently put all that data into the
updateContact
method. Not very ideal.If the developer forgets to do above said things, a user might end up with a contact with only the newly updated phone number, with all "old" data deleted. Not very user friendly.
Approach 2
It would be possible to do a "partial PUT". This would entail that the developer does not have to supply all data, but just the data for the object he is updating. So if, for example, the developer wants to update a contact's phone number, he will only have to supply all the other phone numbers that are supposed to be kept.
This approach has a better developer experience than approach # 1, but it's still not very ideal.
Approach 3
Arguably the best approach is this: make it possible to retrieve the IDs of a contact's phone, email, postal address etc. This way a developer can just specify which object (phone, email, postal address) object should be updated, by simply providing the correct id.
Still this has some quirks that should be thought about. For example:
The developer wants to updated the postal address with id 123. But he only wants to update the street, not all the other fields... What should be done now? Does the developer have to specify all the other "old" fields, so we can overwrite the whole object. Or does the API only update the given fields. But in the latter case, how would it be possible to delete / empty fields?
Of course, this approach, will also take the longest to develop and test.
All in all, still some questions. Unfortunately, I don't have the time, nor the need, to implement this. But of course, suggestions, comments, PRs, or any input for that matter, is very welcome.
The text was updated successfully, but these errors were encountered: