Welcome to the GraphQL World!!!

GraphQL is a query language QL would stand for it’s a query language for your API that’s entirely unlike anything that you’ve ever used before in terms of a standard API.

So in other API s that you’d hit a URL to get data let’s say you want to fetch data from the Rest API that you’ve designed for a retail shop. and you can say hey give me this information. now the way those typically work is that you have a specific endpoint or a URL that you’re hitting and that URL determines what data comes back and you can pass in options to a URL and that can change the shape of the data or maybe what comes back in it but at the end of the day with a normal what’s called a REST API.

Using REST API, you fetch a URL and the URL is returning typically something like JSON or a JavaScript object, full of data and so this is how it’s worked for a while now right, before that we typically we worked with XML and stuff like that now APIs have typically been essentially just REST API for a long time.

in GraphQL it is new and exciting indifferent. well, graph QL aims to improve upon those sort of ideas so instead of an API where you hit a URL and just accept whatever data is coming back, GraphQL allows you to ask for specific kinds of data.

look at the below image,

suppose there is a project with a name, tagline and contributors[1st box]. then you ask for what you want right[ 2nd box] so this is the actual query so instead of hitting an API and just accepting data you say hey give me the project with a name of graph QL and return the tagline okay and then the results come back with exactly what you asked for which is an object with project and tagline rather than just a whole bunch of stuff[3rd box].

in addition to filtering out fields that you aren’t necessarily going to use, GraphQL allows for really excellent relational queries.

so GraphQL is a query language it’s a way to get data from an API into your application, so who owns GraphQL?. well, GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015.

you can use graph QL on any sort of platform so if we go to

https://graphql.org/code/

this site you can see that graph QL is sort of two parts right there’s the server component and there’s the client component. now if an API has a GraphQL server that already exists you can just use that with only client-side GraphQL. and you don’t need to learn the server-side stuff but if you’re building a full-stack app. you need a server library as well. we can see that we go to server libraries and there are categories where you can find GraphQL implementations and all of these different languages.

if we select javascript.

there are many ways we can implement GraphQL servers using Javascript(and any other above languages).

let’s see about client-side(GraphQL Clients)

we can implement GraphQl clients side using the above languages. if we choose javascript there are many options to implement GraphQL clients

below is an example of my gatsby project. I can query data and test the result using GraphQL Browser IDE

Conclusion

So in this small article, my focus is giving a brief idea about GraphQL to you. because developers are moving to GraphQL implementation rather than typical REST API development these days. GraphQL is easy to learn and there are tons of learning materials out there about GraphQL. I think this article helps you to get an idea about this amazing technology, hope to see you guys soon. until then Happy Coding!!!

Software Engineer at hSenid Mobile