Hello everybody,
In the new year, I want to learn how to use GraphQL. Why not using this technology for personnal project or at work. So, for now I will use it with MongoDB at backend and VueJS 2.0 at frontend.
I have a question about how to send query and mutations. Do I need to send directly query like :
"
query {
posts {
_id
title
content
}
}
"
and mutations from client-side (write it at client side) and send it to server endpoint ? (it is secure ?) .
else I was thinking about writing all my queries at backend and simply request post request with action param like "QUERY_POST" and at backend I find my query for "QUERY_POST" and play GraphQL query and send it at vue-side.
What did you think, what is the best way ? I'm a little lost about it. Storing queries and mutations at client side or at server-side ?
Thanks!
nicolasb
Web Developper
Stephan de Vries
Full stack developer, enthusiastic about new technologies.
The whole point of GraphQL is to define queries on the client-side, so you don't have to maintain any API end points on the server.
On the server, you need to define a GraphQL Schema, containing types and mutations. Then you can expose a GraphQL end point. This can be easily done by using something like express-graphql. Have a look at the GraphQL documentation or https://learngraphql.com/.
Hope that helps!