We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies.

We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies. Less

We use cookies and other tracking technologies... More

Login or register
to apply for this job!

Login or register to start contributing with an article!

Login or register
to see more jobs from this company!

Login or register
to boost this post!

Show some love to the author of this blog by giving their post some rocket fuel 🚀.

Login or register to search for your ideal job!

Login or register to start working on this issue!

Engineers who find a new job through Golang Works average a 15% increase in salary 🚀

Blog hero image

What is GraphQl and how it's different from the traditional REST API model?

Ajayjayendran A 2 December, 2019 | 2 min read

GraphQl is often talked about as being part of React or the larger Javascript ecosystem. Though it lends itself well to loading data into react components, GraphQl is just a query language. It does not matter what programming language you use to implement a graph server.

Today GraphQl is used by companies like Pinterest, GitHub, Coursera and it’s gaining popularity due to the ease of use and the performance benefits.

When we often talk about GraphQl, We often talk about how it differs from rest. If you have worked through the API before, you probably encountered rest. There are many flavors of rest, but typically we’ll request or update resources on different Uri’s.

Let’s say we have some data about Tamil Nadu. To fetch all of the data about Tamil Nadu, I could find it at the /api/tamil_nadu route. Then we might make another get a request for some data at the Chennai route. This all starts out very innocently, but rest endpoints have a way of quickly starting to multiply as our data fetching needs expand. If we are looking for people in Tamil Nadu with hats, we might create a custom endpoint for this data. Requesting would require several different requests, one for Tamil Nadu, another for people, then we have to find all of the people with hats in Tamil Nadu. The confusion starts to pile on pretty quickly, and due to this response time can be slower than we would like or slower than is acceptable on mobile networks. An alternative to this is GraphQl.

7cc66961-9208-45c7-99b6-61f36023b08b_Screenshot+2019-11-11+at+1.13.04+PM.jpeg

With GraphQl, we define a query. A query looks a whole lot like a JSON object without the values. Then we send this query as a string to a graphql server. We notice that the response looks a whole lot like a query. Without query, we specify exactly the data that we need and we get nothing more than that. As we change the data that we want to fetch, we can update the query and fill in the fields. The query is nested and issued at once, so here if we are looking for a state with the name, population and people, all of those are going to be nested inside of one another. Then if we need to access the value of fields from one of the objects inside of the people array, we are going to request that once also. This is particularly useful when loading UI components. We’ll populate the components with data and we’ll only ask for it one request.

481936ed-0609-4dd7-b1c8-569aaffbc260_Screenshot+2019-11-11+at+1.31.45+PM.jpeg

Conclusion So GraphQl has a ton of benefits. It defines the shape of the desired data it calls for at once. This way we avoid multiple rest calls and the performance problems of over and under-fetching. It is also backward compatible and version free, meaning you can add new fields to an existing GraphQl server without breaking the current clients and old fields can be deprecated and can still continue to function. We can also use GraphQl to wrap around our existing API. So you don’t need to set up everything from scratch, you can use it as part of your existing setup. Also, GraphQl is a language-agnostic, so you can implement GraphQl solutions in a range of different languages.

Originally published on www.linkedin.com

Author's avatar
Ajayjayendran A
Creative web developer with 3 years’ of well-rounded experience in MERN stack development and dedicated to building and optimizing the performance of user-centric, high-impact websites for nationwide, F500 and global companies. Leverage technical, analytical and problem-solving skills to create dynamic, high-speed websites, apps and platforms fueling competitive advantage and revenue growth. 🤝In my mission, I strive for the following principles: - Define, Design, Develop and Deliver High quality Product. - My client should feel happy at the end. 📎Here are my specialties: - Modern Website Development: from scratch, revamp, update, customize and other forms. - Front end Technologies: HTML, CSS, Js, React, Gatsby, Redux, Webpack, d3.js, Flow, Jest, ESLint. - Back end Technologies: Nodejs, Mongo. - Optimize your existing Web Application. Being a fan of the “think-before-you-act” approach, I prefer to spend some time figuring out a bigger picture of your task/problem before diving into coding. This will prevent you from lots of redos in the future, thus saving our time and money.
    JavaScript
    React
    CSS
    Node

Related Jobs

Related Issues

viebel / klipse-clj
viebel / klipse-clj
  • Open
  • 0
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • Open
  • 0
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • Started
  • 0
  • 1
  • Intermediate
  • Clojure
  • $100
viebel / klipse
  • 1
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • Open
  • 0
  • 0
  • Intermediate
  • Clojure
  • $80
viebel / klipse
  • Open
  • 0
  • 0
  • Advanced
  • Clojure
  • $80
viebel / klipse
  • Started
  • 0
  • 2
  • Advanced
  • Clojure
  • $180
viebel / klipse
  • Open
  • 0
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • Started
  • 0
  • 2
  • Intermediate
  • Clojure
  • $80

Get hired!

Sign up now and apply for roles at companies that interest you.

Engineers who find a new job through Golang Works average a 15% increase in salary.

Start with GithubStart with Stack OverflowStart with Email