I am building an application with VueJS and I am using the Apollo client to retrieve data from a database through a GrapgQL server. I have a code that looks like this:
apollo.query({ query, variables }) // context.commit('populateComments', payload) triggers the mutation .then(payload => context.commit('populateComments', payload))
Then, in my mutations, I have the following
populateComments: (state, payload) => { state.comments = payload.data.comments }
When I try to push another object into an array of comments in another mutation, I get the error "Unable to add property 300, the object is not expanding." I found that the following works
state.comments = Array.from(payload.data.comments)
But .. I'm not sure how efficient it is to repeatedly copy such large arrays? Is this the preferred way to do this?
source share