WHAT IS GRAPHQL?

Let's explain!
This thread is also available in a more readable and accessible format here:

🔗 savvas.me/explained/grap…
You probably heard of GraphQL as a new way to retrieve data from a web service. Possibly as an alternative to REST services. But what is it exactly?
Imagine you need to retrieve some data about a certain user from a web service. The web service is REST based.

To get information about a user if you know the ID of the user is to make a request to a specific URL.
If you're trying to get the details of the user with ID 101, then the URL would be:

api.mydatabase.com/user/101
The user details are returned as a JSON file, like this:
Now, that's a lot of information returned by the web service. You only need specific information, such as the username, the name and surname. Can you only get this specific information?
This can only happen if the developer of the API has specifically added functionality to retrieve specific information and that would be weird and unintuitive with REST-ful services.

Basically in most cases, you're stuck with all this data which most will end up being junk.
What if there was a more explicit way of saying, "I need this information and I don't need anything else?"

ENTER, GRAPHQL!
GraphQL is basically a way of saying something like this:

"I need to get data about a specific user. I only need to get their username, their first name and last name. Nothing less, nothing more."

GraphQL will do it. It will give you exactly what you need.
So how does it work?

We start of with a basic URL:

api.mydatabase.com

This URL will be the same for the entire API, whether we need user data, or anything else.
Next we need our GraphQL statement. The statement to retrieve the username, name and surname from a user with ID 101 would look something like this:
GraphQL will give you back exactly what you asked for in the exact format you requested it:
So not only did it give you back only what you asked for, the response is the exact same format as the request, as if you gave it some blanks and the API filled them in! Isn't that amazing? No more wasted data!
What's next?

I hope this simple explanation helped you understand the basics of GraphQL and why it has become so popular.
To get started with GraphQL, TheNetNinja has an amazing free course on YouTube on how to build your first GraphQL service with Node and React. Enjoy!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Savvas Stephanides

Savvas Stephanides Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @SavvasStephnds

1 Jun
How I made savvas.me

A thread 🧵👇 Image
1⃣ The stack:

I wanted my website to be as fast and snappy as possible.

Which is why this website is 100% Jamstack. The code, posts, assets are all stored in a repository on Github - github.com/savvasStephani….

...and the website itself is made with Gatsby. Image
2⃣ Hosting

For my website, I wanted for the builds to execute immediately after pushing new changes.

The Markdown blog files, the assets (images, videos), JS files, styling etc are all hosted on Github.

The end result from building the website is hosted and managed on Netlify. Image
Read 9 tweets
29 Mar
Should I use forEach() or map()?

Both iterate through arrays in Javascript, but how do they differ? Let's see:

Thread 🧵👇

#100DaysOfCode #CodeNewbie #javascript
🚨 This thread is also available in a more accessible version here:

👇

🌐 savvas.netlify.app/explained/fore…
If you're learning Javascript, sooner or later you'll come across the forEach() and map() functions. It is quite often that there is some confusion about what each one does.
Read 15 tweets
29 Mar
Should I use forEach() or map()?

Both iterate through arrays in Javascript, but how do they differ? Let's see:

Thread 🧵👇

#100DaysOfCode #CodeNewbie #javascript
🚨 This thread is also available in a more accessible version here:

👇

🌐 savvas.netlify.app/explained/fore…
If you're learning Javascript, sooner or later you'll come across the forEach() and map() functions. It is quite often that there is some confusion about what each one does.
Read 15 tweets
3 Dec 20
What is TypeScript?

Let's explain! 🧵👇

#100DaysOfCode
#CodeNewbie
#DEVCommunity
#typescript
🔌 As always, this thread is also available in a more accessible and more permanent space together with my other threads here 👇

🌐 letsexplain.netlify.app/typescript
Take a look at this Javascript code:
Read 20 tweets
12 Nov 20
⚛ What is React?

Let's explain! 👇👇👇

#100DaysOfCode
#CodeNewbies
#DEVCommunity
#reactjs
React is a framework that makes it easier to create complex web pages. How does it do that?
Imagine you're developing a to-do app. Let's say you just need to display 4-5 tasks. Ignore functionality like adding, or marking tasks as complete.
Read 25 tweets
15 Oct 20
What is Docker? Let's explain! 🐋🐳

(Thread) 🧵👇

#100DaysOfCode
#CodeNewbies
#docker
🔌Before I begin: This thread is also available in a more convenient and more accessible format at my new project "Let's Explain" (where you'll find all my other "let's explain" threads as well):

letsexplain.netlify.app/docker
So you've just built a project. Let's say it's a to-do app. There are plenty of things involved:

- front-end
- back-end
- database...
Read 20 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(