-
Notifications
You must be signed in to change notification settings - Fork 19
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
Tutorial enhancement and bug: PATCH doesn't work #228
Comments
So on further analyses, there are a few issues here.
The first issue can be ignored if you have your own back-end. This code works for adding or editing (but not removing all) related entities:
This is notably different from what's in the docs in that it doesn't edit vuex state directly and thus does not cause errors, whereas the PATCH examples currently in the docs fall into that trap. |
Relates to: #187 |
There's a lot going on in this issue; there are probably several issues under the hood. I'll need to ask some questions to even understand what's going on. When you say:
What exact information are you seeing where?
Where does the spec say this?
I'm going to need more details than this to evaluate whether something is wrong and update it. Please provide details. |
https://vuex.reststate.codingitwrong.com/writing-data.html#update
On re-reading it perhaps it doesn't. I assumed it did because my back-end JSONAPI service does not support it and also because the spec only shows an example of removeAll for relationhips PATCH requests (in https://jsonapi.org/format/#crud-updating-to-many-relationships).
The documentation (https://vuex.reststate.codingitwrong.com/writing-data.html#update) shows this:
However this will cause a vuex warning as it is directly editing state without going via a mutator when it does this |
+1 also getting this for patches with empty relationships |
I experience the same error after a siple one-attribute update action.
I found out that this piece of the core is bugged:
When the original record had loaded some relationship and you are doing update operation, then your server will most likely will NOT respond with that relationship. That will cause the EDIT: The solution here is imho to not update the relationships we had in original record but only those ones which server responded. If server doesn't respond with any relationships we should not even call the |
FYI, this library will be unmaintained going forward. If you need new features or fixes, I recommend forking the repo and making changes, or finding an alternate library that meets your needs. |
Hi,
The tutorial doesn't seem to cover PATCH. It would be great to see:
I notice that there's some information in at the end of the readme, but it doesn't seem to work. I get errors.
Here's my code:
This is as per the docs, however it generates the following errors:
I also tried it a different way; creating a new object without
links
orrelationship
(as both these properties are rejected by the HowToJSON server):This actually works (i.e. the PATCH executes) but also results in a different error:
I think the bug is here:
reststate-vuex/src/reststate-vuex.js
Line 325 in 04c9647
Maybe it shouldn't update relationships if the submitted record doesn't contain any? I'm not sure... looking at
getRelationshipType
it seems to be looking for adata
property in therelationships
object... but looking at the vuex data loaded from even those restaurants that do have relateddishes
, none of them have adata
node in therelationships
property. Seems spurious to me.The text was updated successfully, but these errors were encountered: