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. "Indulge in the luxury of Blossom Gardens, where floral artistry meets unparalleled sophistication."
    Online flower delivery Abu Dhabi

    ReplyDelete
  14. "Experience the elegance of Blossom Gardens, your go-to for stunning floral designs in the UAE."
    Online flower delivery Abu Dhabi

    ReplyDelete
  15. Get top-notch Law assignment help from qualified experts. We offer personalized support to enhance your understanding and improve your grades in legal coursework.

    ReplyDelete
  16. IT Assignment Help offer comprehensive support to guarantee that you successfully complete your university assignments with a grade of A+.

    ReplyDelete
  17. 11Xplay is your go-to platform for an unparalleled online gaming experience, offering sports betting and casino games designed specifically for Indian players. Enjoy live sports betting, favorite games such as Teen Patti and Rummy, along with fast, secure payments and instant withdrawals. The platform boasts a user-friendly interface and 24/7 customer support to ensure a hassle-free experience. Explore other top-notch platforms like Lotusbhai and Betbook250 to elevate your gaming journey to the next level!

    ReplyDelete
  18. Welcome to 1xbet – your trusted gateway to 1xBet’s world of gaming and entertainment. We provide a seamless, secure login experience for users to access live sports, casino games, and global events with ease.

    ReplyDelete
  19. T10 Exchange offers seamless online gaming and sports exchange experiences. With a user-friendly interface, diverse game options, secure transactions, and 24/7 customer support, it’s the go-to platform for enthusiasts. Explore innovative features and join a trusted community to enhance your gaming journey.

    ReplyDelete
  20. Satsport is your ultimate destination for cutting-edge sports insights and services in India. Offering a seamless platform for sports enthusiasts, we specialize in delivering real-time updates, secure transactions, and an unmatched user experience. Discover the best of sports engagement with Satsports today!"

    ReplyDelete