Skip to content

Best practices: Where to put the GraphQL data fetching #1240

Answered by smolinari
tobiasdiez asked this question in Q&A
Discussion options

You must be logged in to vote

I personally like the first one for querying. In fact, I think this is why GraphQL is even a thing. Facebook wanted querying to be part of each component. So, if you use a component anywhere, it pulls the data it needs, as it needs it. IMHO, component data is the 4th realm of responsibility covered in SFCs (next to JS, HTML, CSS) and needs to be involved in terms of reusability. Mutations are a different beast though, as they could kick-off or rather be needed in different types of processing. So, mutations are not as black and white.

Scott

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Akryum
Comment options

Answer selected by tobiasdiez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants