Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: support for updating a contact #86

Open
tafelnl opened this issue Dec 18, 2022 · 2 comments
Open

RFC: support for updating a contact #86

tafelnl opened this issue Dec 18, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@tafelnl
Copy link
Member

tafelnl commented Dec 18, 2022

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.

@tafelnl tafelnl added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Dec 18, 2022
@tafelnl tafelnl changed the title feat: add support for updating a contact RFC: support for updating a contact Mar 10, 2023
@jameshhood
Copy link

I'm not sure about the underlying code but since most of the data is already present when you get a contact; I'm sure we could just update what we need and approach 1 would at least get us around having to store, delete, and create the entire contact again. Not sure if that would even work if there are notes and other things associated with it.

I'm currently making a support contact in my app and for now I only need a single number but I would like to be able to manage that number and potentially add more numbers to that contact based on certain departments.

@tafelnl
Copy link
Member Author

tafelnl commented Jun 6, 2023

However because of the drawbacks mentioned, I'm not in favor of using that approach. Moreover it would be kind of misleading to a developer and one might not be aware of the caveats. And essentially this approach is already possible by using the current API, by means of just getting, deleting and creating a contact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants