1
votes

I am building a Nuxt app with a GraphQL API, connected via the nuxt module of Vue Apollo.

I'm currently using Vuex to store app-wide things, and in this one specific case a property called alert. The alert object stored in Vuex tells me what type of alert it is, what its message is, and whether it's active or not.

Since introducing GraphQL to my app though, I was wondering if it's possible to store that type of state data through Vue Apollo instead of Vuex? I read this in the documentation... would this be a better solution than mixing Vuex with Apollo, or is it better to separate state so that app-wide state is handled with Vuex, and API state is handled with Apollo?

2

2 Answers

1
votes

Yes, it is better to separate the state so that the app-wide state is handled with Vuex, and the API state is handled with Apollo?

This will EXTRACT DATA LAYER which will be S.O.L.I.D compatible.

1
votes

No. Vuex combined with apollo creates two different truths aka. duplicate information. As documentation suggest apollo is able to handle local states the same way as vuex, but using the graphql way.

Take a look at: Apollo local state and Nuxt local state example