Best practices: Where to put the GraphQL data fetching #1240
-
What are the established best practices concerning the question of how tightly vue components should be coupled to the GraphQL fetching. I guess there are two main lines:
When should one use which approach? Are the alternatives? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
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