How GraphQL Is Changing The Game
March 30, 2020
For most of us software developers, we started our database work with SQL and relational databases. We usually then gravitate towards noSQL and all that good stuff. However, I find that many software developers don’t make a critical, third step: GraphQL.
What is GraphQL?
Simply put, GraphQL is a programming language used to query graph databases. Now, what are graph databases? Refer to the image above. It is essentially a bunch of nodes (in the image’s case, faces) that have connections (or none at all) to the other existing nodes.
GraphQL was created by Facebook to better manage all of the different users and friends said user might have. As it turns out, it works well in quickly querying and accumulating a specific user’s data.
A quick example
Now that we have a general idea of what GraphQL is, I want to run through a quick example of how easy it is.
Take, for example, the image I mentioned above again. Our IronMan face has three connections: Sunglasses, Caticorn, and Doge. Now, what if we want to figure that out using GraphQL? It would look something like the following:
query {
face {
name
connections {
name
}
}
}
And what is returned from the query has the same structure as our query, except it has the data we want.
{
"data": {
"face": {
"name": "IronMan",
"connections": [
{
"name": "Sunglasses",
},
{
"name": "Caticorn",
},
{
"name": "Doge",
}
]
}
}
}
As you can see, GraphQL queries are intuitive, and the data they return can be easily accessed in programming languages. Compare that to SQL where a query looks more like:
SELECT F.NAME, F.CONNECTIONS
FROM FACE F
WHERE F.NAME = 'IronMan';
and returns a bunch of columns that the programmer will need to convert to a list or something similar.
A Future Game-Changer
While GraphQL is a relatively new technology and it does not have the users that the more traditional programming languages have, it outperforms many other new technologies in many categories. However, there is one specific category that it blows everything else out of the water: intuition.
Ever since I have been a professional software developer, one of the greatest challenges I have come across is connecting the engineering teams to the business teams. I believe that some of the tasks software developers do seem intimidating at first to people outside our field (this was the case for me when I started). Our code looks like gibberish to most people, our jargon can be hard to follow, and some of us come across as weirdos, myself included. What GraphQL indirectly does is help bridge this gap.
Rather than building another language that makes sense to solely programmers, Facebook built something that most any person can understand with a few minutes of explanation. I am not asking the business folks to be programmers, but I do believe that programming languages such as this will help them better understand our profession, and thus, better understand the work that is required to deliver certain features.
Right now there seems to be a divide between tech and many other professions, GraphQL is a small step to help bridge that gap.
Sources
GraphQL’s Website: https://graphql.org