GraphQL is one of the most modern ways of building and querying APIs. With GraphQL, the user is able to make a single call to fetch the required information rather than to construct several REST requests to fetch the same. GraphQL is a mainly a language used to receive exact data based on your queries. For example, take a look at the below query.
{
viewer {
login
bio
organizations(first: 3) {
edges {
org:node {
name
}
}
}
}
}
The query above will generate a response by retrieving the login and bio of the user along with details of the first three organizations:
{
"data": {
"viewer": {
"login": "abctest",
"bio": "sample test",
"organizations": {
"edges": [
{
"org": {
"name": "company"
}
},
{
“org”: {
“name”: “Atom”
}
},
{
“org”: {
“name”: “sample name”
}
}
]
}
}
}
}
GitHub and GraphQL
GitHub uses GraphQL as it offers more flexibility for the developers. The option to precisely generate the information that a user wants is a great advantage over sending multiple REST calls to receive the same. To generate the information based on the above example using REST calls would require a two stage process – One to gather the information of the user and the other to fetch the information about the organization the user is associated with. GraphQL helps alleviate this two-step process.
GraphQL is one of the more recent app development tools to be generated form Facebook’s open-source internal libraries. GraphQL is a specification with usage aspects linked to several well-used languages and is not an all-out framework, tool or library. An official reference implementation is available that is written in Javascript along with other popular libraries for Ruby, Java, Python and PHP to make it easier for prospective users.
GraphQL Is Great For Developers
It would be wise for any developer, be it the ones familiar with React, Angular, Ember, iOS or Android, to take time and learn about GraphQL and to slowly but steadily start using it. There are many communities extending support to beginners who are using GraphQL. A few are Slack channel, Apollo and GraphQL GitHub organization. Be sure to pay their portals a visit for updates and support content.
Rest Just Doesn’t Cut It
Take a look at the image below and you’ll get a better picture:
GraphQL is a layer between servers and clients far more intricate and efficient than what REST could provide. I would urge you to visit the links below for more information:
• From REST to GraphQL by Jacob Gillespie
• GraphQL at The Financial Times by Victor Charypar
• The Business Case for GraphQL by James Baxley III
• Adopting GraphQL by Arunoda Susiripala
Many other options are available as well. A simple Google search will get you a barrage of sites and blogs supporting the use of GraphQL and its importance.
You Are Already Using GraphQL
GraphQL is fundamental to how Facebook works. With over one billion active users, it’s safe to say that using Facebook quite literally means using GraphQL.Facebook started used GraphQL in 2012, way before it was open-sourced in July of last year. Since then there has been a rapid growth in terms of the number of developers using GraphQL and its associated communities. Many companies are now turning to GraphQL as they understand its significance and future prospects.
- REFERENCE LIST:
http://graphql.org/
http://dev.apollodata.com/react/
https://code.facebook.com/posts/1691455094417024/graphql-a-data-query-language/