Hi everyone! This is the time for a new article series. What's it? Have you heard of GraphQL? Anything you know already? Some may have no idea of this GraphQL. This article is specifically for them...for Beginners!! So, what's GraphQL?

GraphQL is an open-source data query and manipulation language developed by Facebook. It's used to deal with data which are having relationships like graphs. When we develop applications, this language can be used to handle data in a more efficient way with high performance. The below image shows you what that Facebook tells about GraphQL in their official website.

How GraphQL is used?

You may have already heard about REST APIs. There we simply send a HTTP request to a server and get a response as a result. There we have API endpoints which means the URLs we need to call for a result. In our API code, we define them. So we define the queries to get data from a database during our API development.

E.g: We need to implement an API for a library. Basic one..Functionalities will be;
1. Get details of all books
2. Get details of a book by it's ID/ISBN
3. Get details of all authors
4. Get details of an author by his/her ID

The structure of the API and front-end will be like this...



When we introduce GraphQL into this setup, structure is going to be like this in abstract.


Here we are using GraphQL in our back-end API(server) to retrieve, modify data in a database. So we have to use client libraries according to the languages we are using in both front-end and back-end. As an example, If we use Express JS as back-end, we have to install some NPM packages into the code and manipulate data stored in any kind of database(let say MongoDB), using it. If we use React for front-end, we have to install and use a client to talk with GraphQL endpoints. Apollo is such client used to send requests to back-end with React.

How GraphQL works?

At the beginning, I told you that using GraphQL is more efficient. I can explain the processing that helps efficiency and performance in GraphQL, using its main features described below.


1. Ask for what you need, get exactly that

Let's take the above library scenario. We are going to retrieve all the books as a list from database. In our usual way, we write a code to perform a query to get all the Book objects. Every object has many fields like id, title, category, author, ISBN.....But if we do not need this ISBN to the UI? Results are already having this field in every object. So, it's a waste. When we use GraphQL, we can define data we need, before sending a query. This is the main benefit.


2. Get many resources in a single request

Imagine that when we retrieve all the books. As I told, we have a field called author in each object. In normal way of performing queries, we get the author name only. If we want to get the books written by the same author with this same request? Usually we have to call another API endpoint with author ID, to fetch the books written by an author. There we find the usage of GraphQL. It considers data as nodes in a graph and sends data looking at the relations. Look at the below one.


Here, if we need Book(3), GraphQL will look at the Book with ID 3 first. Then title and category are taken. It's connected with Author. So GraphQL go into that object also. From this, author's name and age are taken. The author has written another two books => Book(4), Book(5). So, their details are also retrieved. Finally it will send the data including it's title and category + author object + books objects as the Book object we need.


It can wrap the author's publications also along with the response when we request to retrieve all books. Then our requirement is fulfilled with one request!! We get many resources in a single request! That's why this GraphQL is said to be efficient. 


3. Describe what’s possible with a Type system

When GraphQL is introduced to the back-end, we can define the entity class as we want. Then the retrieving data will be in this format. We have to define the classes properly. Look at the below setup.


In the scenario we discussed, we have to setup the Type in a way like this. You can see how they are related to each other. In the Left side, GraphQL query format is shown. In the Right side you can see the way to define the schema to deal with data.

Now I think you have a basic idea about GraphQL guys!!! This technology is already used by a lot of famous brands like Facebook, Twitter, Pinterest, Paypal, Amplitude, Dailymotion, Atlassian and etc.

You got the idea how it's said to be efficient and fast? I just needed to give a brief but in detailed introduction to this amazing query language. I tried my best to share the things I know with you. If you want to learn more, go to their official site from here => https://graphql.org
Hope you will get something from this article..

Thank You!



22 Comments

  1. selamat kamu menemukan artikel yang tepat. Sebab kali ini kami akan membahas bagaimana cara main poker online uang asli tanpa rekening bank.
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terbaik
    hobiqq
    paito warna
    bocoran sgp
    data hk

    ReplyDelete
  2. Thank you for sharing this post, you have given very good information in this post so that you can understand it better in reading weliv.online To purchase any type of product, visit our site so that you can actually purchase the product.

    ReplyDelete
  3. Prettify Creative are a team of expert Graphics Designer in Gurgaon .Prettify Creative will allow you to connect with customers, build your brand and achieve online visibility.

    ReplyDelete

  4. Empower your children with 1-on-1 math learning with Mindzq! Our Expert Math Tutors tailor their lessons to make learning fun. Book your free class today. Math Tutoring in Fair Lawn.Tutoring Math in Fair Lawn

    ReplyDelete
  5. Intellicept is one of the best IT recruitment agencies with expert industry knowledge. Our trained headhunters find the top information technology talent in the country. IT Recruitment Agencies

    ReplyDelete
  6. Free GST Query through GST Experts of better GST compliances and handle GST interpretations. Free GST Query

    ReplyDelete
  7. nice post.
    Softcron Technology is a team of talented youth quided by the expertise of Digital Marketing Website Designer, Website Developers and Graphic Desiqners, Best seo services in Rohtak we put our best effort on every single website project considering it as our own site. We aim to deliver best services to our clients and hello them to grow in the competitive industry. We focus on taking your business to the next level with the help of right branding strategies and online marketing campaigns.
    Digital marketing service in rohtak
    Digital marketing services in rohtak
    Best seo services in Rohtak
    Seo services in rohtak
    Bulk sms in rohtak
    Bulk sms services in rohtak

    ReplyDelete
  8. Intellicept is one of the best Mobile App Development Company with more than 10 years of experience. It delivers best result-driven android and IOS Mobile Apps across the industry. Mobile app development company

    ReplyDelete
  9. Gsquare provides professional 6 months industrial training in mohali. Learn from experienced trainers and get certified in courses like Python, Java, Web Development, and more. Join now and take your career to the next level!

    ReplyDelete
  10. Everything has its value. Thanks for sharing this informative information with us. GOOD works! a href="https://americanlifeguardassociation.com/lifeguard-course/">lifeguard course near me

    ReplyDelete
  11. I am new to graphql api and was surfing through whole internet to get the basin gist of it and you blog really helped me understand how the whole graph ql works.
    Thankyou and keep it up.

    ReplyDelete
  12. Excellent information on your blog, thank you for taking the time to share with us. Looking to boost your video's visibility and reach a wider audience? Look no further! Discover the ultimate compilation of Video Submission Sites that will skyrocket your rankings.
    For more info visit Free Video Submission Sites List

    ReplyDelete
  13. The Dab Rig Mystery Box is more than just a collection of random items. It is a carefully crafted package that combines the thrill of surprise with the assurance of quality products. When purchasing a Dab Rig Mystery Box, you can expect a diverse range of high-quality accessories and essentials to enhance your dabbing experience. The box may include a premium dab rig made from durable materials such as glass or quartz, along with essential tools like a quartz banger, dabber, and carb cap. Additionally, you might find cleaning supplies to help maintain your dab rig's longevity. Some mystery boxes may also include extra surprises like novelty items or unique dab concentrates. Each box offers a thrilling surprise and an opportunity to discover new products for your dabbing pleasure.

    What Items Populate The Oil Burner Mystery Box?
    What To Expect In The Dab Rig Mystery Box?
    Best Gift For 420 Weed Day In 2024
    How Much Is A Weed Box $24.99 To $149.99
    What To Expect In The Dab Rig Mystery Box?

    ReplyDelete
  14. "Indulge in the luxury of Blossom Gardens, where floral artistry meets unparalleled sophistication."
    Online flower delivery Abu Dhabi

    ReplyDelete

  15. Experience the elegance of Blossom Gardens, your go-to for stunning floral designs in the UAE."
    Flower store Abu Dhabi

    ReplyDelete
  16. "Step into the world of Blossom Gardens, where floral dreams come to life in the heart of the UAE."
    Flower shop Abu Dhabi

    ReplyDelete

  17. "At Blossom Gardens, we craft floral masterpieces that captivate the senses and elevate any occasion."
    Florist in UAE

    ReplyDelete
  18. "Indulge in the luxury of Blossom Gardens, where floral artistry meets unparalleled sophistication."
    Online flower delivery Abu Dhabi

    ReplyDelete

  19. Experience the elegance of Blossom Gardens, your go-to for stunning floral designs in the UAE."
    Flower store Abu Dhabi

    ReplyDelete

  20. "At Blossom Gardens, we craft floral masterpieces that captivate the senses and elevate any occasion."
    Florist in UAE

    ReplyDelete