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

Pattern for updating an existing Resource? #92

Open
lukemelia opened this issue Feb 23, 2019 · 2 comments
Open

Pattern for updating an existing Resource? #92

lukemelia opened this issue Feb 23, 2019 · 2 comments

Comments

@lukemelia
Copy link

If I get an updated JSON-API string back from the server is there a way to use it to update an existing Resource instance rather than creating a new one? I didn't see anything in the docs or code about this, so I thought I would ask how others have approached this.

@kamikat
Copy link
Owner

kamikat commented Feb 25, 2019

Resource object is designed immutable. And it can't parse a JSON to update itself I think.

@lukemelia
Copy link
Author

@kamikat Thanks for the response. I appreciate it.

I think that I don't have a clear idea of what update patterns should look like with moshi/moshi-jsonapi.

If I have a simple form to update the name and email address of a person. And I have Person resource object, I imagined that I would call person.setName(...) and person.setEmail(...)` and then generate json from the person's document to make a PUT request to the JSON-API endpoint. I would then take the response and use it to update the person resource.

It sounds like you're saying that is not possible or recommended. How would you suggest handling this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants