-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
The returned data are not reactive anymore #68
Comments
The data coming from Apollo is immutable. I recommend you to use a new data property if you want to modify it. |
@tadejstanic apollo object is freezed you need to create other if you want use it with inputs and editing it i using Example:
|
At first, I was also looking for a solution in both proposed directions, which ends in new data property. But I thought we can do this at 'SmartQuery' level when vue-apollo assign the results to the component data properties. So what do you think about this modification in 'smart-apollo.js':
|
This modification might be nice to include, I find myself copying objects lots. I typically use |
Personally, i prefer the approach as is. It aligns with flux in that there is a one way flow of data. Apollo gets data, vue-apollo maps it in and then pass those down as props to other components. By letting any one of those components update the object, you lose flux. |
@Samuell1 your example seems to not work :( but when i change this.data to this.Post, it worked :). Thanks a lot 👍 |
@Musbell yeah, because you need create
|
@Samuell1 noted :) |
Thank you to the participants on this thread - I just got caught on this issue as well. I'd strongly recommend adding something to the docs (maybe in "basic usage") that calls out the fact that data coming back from queries should not be mutated. Consider using the "warning" or "danger" style to really make sure everyone sees it. |
@dweldon its in Apollo client docs. |
@Samuell1 Thanks for pointing that out. Many users (myself included) may not need to use the apollo client directly, and therefore haven't done a careful read of its documentation before coming to vue-apollo. While I agree this may be a case of RTFM, it seems like this is an opportunity to prevent new users from getting confused. |
@dweldon but vue-apollo is using apollo client directly, because its just integration but i know what you mean, maybe there should be link with explanation in docs somewhere. Looks like it will be soon resolved and not needed? apollographql/apollo-client#3883 |
When 'vue-apollo' gets a result from 'apollo-client' via 'SmartQuery' and sets the result to component properties, I found those properties are not reactive anymore. This problem arises when you use 'v-model' where a user wants to update previously received data.
To get a picture of the problem see the code from a fictional vue component:
I want to know if this is a bug or expected behavior?
The text was updated successfully, but these errors were encountered: