DEV Community

Discussion on: Opinionated React: State Management

Collapse
 
farazamiruddin profile image
faraz ahmad • Edited

I actually wrote about this here :)

dev.to/farazamiruddin/an-opinionat...

Collapse
 
amerzel profile image
James Whiteneck

Thanks for the response :) I enjoyed that article too. My question was if you would merge the two approaches here if you were using both Apollo and some sort of state management. In this article the data fetching was abstracted into a separate service. What's your thought process on deciding if the data fetching should be within the component or within a separate service?

Thread Thread
 
farazamiruddin profile image
faraz ahmad • Edited

Personally, I like to keep non-graphql data fetching in a separate file. This keeps my view logic & data logic isolated.

However, for graphql, the way I use it at least, the shape of the graphql query is tied to the component that is using it. so that is why I keep my graphql queries co-located in my react component.

hopefully that makes sense lol.