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
PATCH issue with links #59
Comments
As a side note, really loving the work you guys have been doing with this Vuex package @mrichar1. |
Thanks for raising this issue. I've revisited the spec, and it says the following for
So the use of links is both allowed, and actually has a specific purpose (in providing the patch URL via the I've looked at In the short term the workaround is to drop the
If there's a general need then I could potentially put in a helper function to make modifying the normalised data easier for patching, but otherwise it's easiest for the developer to just modify the data as they know best what they do and don't want in the patch. (It's generally always a god idea to have an mostly empty patch with onlt the changed attributes in it anyway, to avoid issues where a locally cached value overwrites a later-updated one on the server). |
Thanks a lot Matthew for the thorough explanation here on how to proceed. Your snippet here is excellent. Where would you recommend I do this in the code base? I should probably just continue to maintain my own fork for now then correct? |
I'd always prefer to accept changes into the main project - forks are useful, but if I can support your needs here, so much the better! If the simple snippet above is enough, then you could run it either at the point you return data from the
Alternatively, you can modify the data just before calling
In terms of helper methods, I can think of a couple of different ways of doing it. The first is to make a method that does the
The second is to make a method, equivalent to the
I don't know if either of these approaches is useful or viable, but it's the kind of thing that could be added to the project, rather than forcing you to maintain a fork for this kind of behaviour. |
Thanks for all these options Matthew. I went with your third suggestion to build a helper method for this:
Your feedback and suggestions are tremendously appreciated man. Thanks for being so responsive to a new Vue developer who is still very green in this space. |
When dispatching
jv/patch
actions I am getting a status400
. The generated payload looks good, and I have compared it to the json shown at the official json api website: https://jsonapi.org/format/#crud-updating.The server I have implemented is on Rails, and has been around for quite a while with a lot of traction: https://github.com/cerebris/jsonapi-resources.
After doing some investigation, it appears the presence of the
links
is what is causing these PATCH requests to fail. I am not positive if these links should be present in PATCH requests or not, but removing them would most likely conform to more JSON Api server implementations out there.The text was updated successfully, but these errors were encountered: