DEV Community

Discussion on: Move subscribeToMore to be more declarative by moving it to the template

Collapse
 
vladimirnovick profile image
Vladimir Novick

Hey. So let me elaborate on that.
GraphQL is a query language to your APIs so nothing to do with queries to database.

In our single page app on a client, we have a VueJS component file with template where we can embed other components. Whenever we want to query GraphQL endpoint basically what we do under the hood is call POST request and pass specific query GraphQL syntax to our server. In our use case it's Hasura GraphQL endpoint. Now this definitely needs abstraction as you mentioned and this abstraction is what ApolloClient is about. So it is sending requests to the server. Now ApolloSubscribeToMore or ApolloQuery component are basically components that under the hood use ApolloClient to execute this query to the server. So also an abstraction. The benefits of doing this is because you have your component as a Unit. it handles view updates and queries the server. ApolloClient handles the cache and everything.

For GraphQL in general I suggest you to check my GraphQL bootcamp where I explain what GraphQL is all about here: youtube.com/channel/UCxiXx-gMssQnY...

Collapse
 
alexflorea2 profile image
Alexandru Florea

Thank you for clarifying that! I definitely need to read more about the subject