GraphQL, and also Anime! 🥤🍿 🧑💻
Hello fellow readers! Let’s jump into another exciting topic, GraphQL! Will cover what it is, What it does, and why it’s becoming so popular to use for modern-day developers. So without further ado, let’s jump into this amazing Facebook-created technology.
Before we get into GraphQL, I’d like to set the tone with some context. We need to understand one important point about software development. People make products like OS, games, and web apps with Users in mind. Often a product has to compete for the buyers' attention; there are many ways you can do this—a suite of features, no-brainer user interface, low latency, and overall snappy performance.
In this Olympic arena of competition, every minor improvement counts. Shaving milliseconds off of a search engine actually adds measurable value. Considering this climate, it’s no surprise that companies are always striving to produce the most quality product for their users. This is the primordial soup that GraphQL spawned from. 🌊 🦎
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. On 7 November 2018, the GraphQL project was moved from Facebook to the newly-established GraphQL Foundation, hosted by the non-profit Linux Foundation. Since 2012, GraphQL's rise has followed the adoption timeline as set out by Lee Byron, GraphQL's creator, with accuracy. Byron's goal is to make GraphQL omnipresent across web platforms....- Wikipedia
Okay, but WHAT IS… GraphQL?
It’s a way to speak to a database, just like REST can. It can do this flexibly by cutting down the back and forth communication from your app to the database. This method can be much more efficient than the traditional REST method.
How does it do this?
Simply put, It uses its own syntax(Type system) to write schemas, queries, and mutations(writing to the database) that are different from the standard REST.
We pair this with Introspection, which allows us to see which APIs will have access. Think of it as a way to navigate through the structure of the API.
More on Introspection
Let’s say I wanted to grab my friends’ cell phone number from a database. If I requested this database via the REST method, I’d get back a lot of information. Not only would I get their cell number, but I would also get their address, cat’s name, blood type, birthday, etc.
So why should I care?
There are a few problems here. Let’s say if 50 users all decided to request their friend’s phone number, that’s a lot of data going out. We ideally need to minimize all the traffic. Yet if we only sent a phone number, it’s measurably better.
Another issue here is the cost; databases aren’t free. You have to pay for space, reads, and writes. Which makes you think twice about sending over whole tables of information, right? See the advantage!
GraphQL is pretty hand, right?😀 Constantly going to your database can cost you big bucks 💵 and considerably slow down the user experience 🐢 . It’s definitely worth looking into for future projects. Before you go all crazy with it, please remember. In the end, it’s just a set of tools🧰 to use to help solve certain problems 🧮 . Like most things, it has its pros 😌 and its cons 😭 . Make sure you understand them both, or you may have a massive problem on your hands.
Happy Coding 🤠
Cool Links 😎
Wiki on GraphQL - https://en.wikipedia.org/wiki/GraphQLGreat Blog on GraphQL - https://medium.com/@ignaciochiazzo/introspection-in-graphql-a5a5bd744a66Docs on GraphQL - https://graphql.org/