What is GraphQL and how to use it

Aditya Sridhar on December 23, 2018

This post was originally published in adityasridhar.com What is GraphQL? It is basically a query language for API's GraphQL shows wh... [Read Full]
markdown guide
 

Thanks for the tutorial Aditya!

Question: When does the resolve for movies get executed for a directorType? Does it run the function every time you call for a director, or does this code run beforehand and is cached in case the user makes a call for a director's movies?

Thanks!

 

That's a really good question.

It would run every time you call for a director. And in a Real application that resolve function may end up calling a DB or making a HTTP request.

To make this more efficient a cache could be implemented so that the DB or HTTP call can be avoided whenever possible. But the cache implementation would be specific to your application.

 

In this tutorial you're testing the input/output by the Graphiql web UI.
How would I make the request from within the code, instead of the UI?

 

You could send a HTTP POST request to the graphql server. For example using curl you can call the hello endpoint as follows

curl -X POST -H "Content-Type: application/json" -d "{\"query\": \"{ hello }\"}" http://localhost:5000/graphql

You can checkout the following url to know more about accessing the graphql endpoints from a client.

graphql.org/graphql-js/graphql-cli...

 

@aditya Nice Tutorials. First time understand the graphql concepts clearly. Thanks.

 
 

Thanks alot for the tutorial!
It was a really nice introduction to GraphQL, great work.

 

Ooooh, great tuto Aditya!!!

Simple and direct. Now I'm ready to learn more about GraphQL.

Thanks.

 
 
code of conduct - report abuse