GraphQL and Africa, a technological game changer: The history, open source and hamburgers
Posted by Content
Imagine this. It's been a long day, everything that could go wrong - did. Worse still, you´re absolutely starving. You navigate traffic while listening to your “whine down” Spotify playlist, and have convinced yourself that it’s in your best interest to have a third cheat day this week.
You guessed it, we're going to McDonald's with you!
Fast forward - you find yourself in their iconic “drive-thru” queue, three cars ahead and four cars behind. Your mood has improved and the wait doesn't bother you one bit whilst humming, “mmmmm I'm loving it!”.
Oh look again, there's only one car in front of you now, and you simply can't contain yourself with all the juicy, buggery goodness coming your way. The car ahead receives their parcel and presto, it's your turn now. You panic. In all the excitement, you haven't decided what you actually want! This is particularly troublesome for you because you're what some may call, ´a burger connoisseur´… or, as your partner likely calls it, ´fussy´.
“Welcome to McDonald's, may I take your order?”, the charming waiter enthusiastically asks. You study the menu, and to your amazement, find 42 distinct and appetizing burger combos - chips and drink included. Only 42 options.
You focus and decide it's chicken for you today, “Heya! All well?! May I please have a chicken burger, no onion, extra gherkins, BBQ-sauce instead of ketchup, no fries and a diet coke”.
The infinitely patient attendant smiles and says, “My sincerest apologies, you will have to choose one of the 42 burger combos on the menu to your left sir. No rush, take your time. Oh, and we will also have to give you the fries”.
To which you reply, “Oh, I’ve seen your menu, great stuff. However, for me, there’s nothing in the 42 combos that I want. Surely you could just cater for my changes - it shouldn’t be any trouble for you, no? Oh, and I’m happy to cover the cost of the ‘extra gherkins’ bit as well. Wait, what did you mean by ‘have to give you the fries’?”. To which our lovely attendant then responds, “Totally understand, unfortunately, we can’t cater for changes. The menu combos are all there is. If you would like, I could suggest to my manager a new combo to suit you. If there are enough people like you, we could have it added to the menu! Then we’d have 43 combos! Oh, and maybe you could choose the name … we would still have to include the fries though. All our combos MUST come with fries.”
Well reader, I’ll stop our little McDonald’s drive-thru chronicle right there as I assume you’re either salivating or angry at our imaginary attendant… or perhaps at me. However, before you lash out in frustration, I’d like to take a moment to congratulate you!
You now know, intimately, how all significant APIs on the internet used to work just under a decade ago! It was utterly frustrating, even more so in 2021 because we now have a viable alternative - but we will dive into this in a bit.
We’re going to have to enter some dangerous territory now. I’m going to make some assumptions and take a few logical leaps as to who you are and what you know.
I’m going to assume that you know what an API is and its general purpose. If not, I got you, have a quick look here - Auth0.com, 2021 to read or Mulesoft, 2015 to watch.
With your knowledge of SOAP and RESTful APIs in our left hand and a burger in the right, let’s get to the meat (or patty) of our discussion :)
Much like the predetermined, ‘ready to rumble’, 42 burger combos, SOAP and RESTful APIs were and are fast, predictable and by and large, a pleasure to handle. So in all sincerity, given the circumstances they found themselves born into, they really served a fantastic and practical purpose! Sort of like horses and carriages before Ford’s production line.
Options! We not only want them, but in 2021 where terabytes of data are exchanging all around us every day - we simply need them. Enter GraphQL.
First, we need one more piece before we can fly: “what is meant by the ‘Graph’ before the QL”?!
For this, we quickly turn to the source of all things logical - mathematics and its descendant computational science;
“A graph is an abstract data type that can be used to represent complex, non-linear relationships between objects. A graph consists of nodes (also called vertices) that are connected by edges (also called arcs). Graphs have a lot of key terms: When two nodes are connected by an edge, they are called neighbours.”
The thing is, for decades we’ve been extracting, transforming and loading data into two-dimensional, “Excel ready” templates as though the phenomena we are recording exhibits such characteristics. In the end, we are left with little or no choice but to alter the flow of reality as it seeks to be, instead of altering the 2-D model we've boxed ourselves into. Like the fixed McDonald’s burger menu.
In all reality, any reputable mass-market burger establishment in 2021 should be able to deliver an infinite amount of combinations of burgers to any one client (well ok, there are nCr = n!r!(n−r)!n! many combinations of burgers, assuming no repetitions of ingredients - but, who's really counting?!).
This ‘death by so many possibilities' is why in 2014, McDonald's launched their “Create Your Taste” burger customization. After some trial and error in different regions, they’ve since settled with their "Signature Crafted Recipes” to better accommodate operational efficiencies at scale, for all outlets (if not, most). [Business Insider, 2016]
Knowing what we now know, let’s turn to Africa.
In 2017, Facebook cleaned up their mission statement, "To give people the power to build community and bring the world closer together." (M. Zuckerburg, 2017) (one can argue that it has, long since before 2017, been their ethos).
In an attempt to fulfil their mission in Africa, two major obstacles were apparent for broad based adoption;
- Access to cheap/free internet with sufficient bandwidth and
- Given the above obstacle, an efficient means to interact with the actual platform.
Focusing on the second point (I'll let you catch up on the first one and the time Elon blew up Mark's AMOS-6 satellite here) Africa's use of mobile devices was on the rise!
This was helped by relatively cheap access to entry-level smartphones and her burgeoning youth adopting such access, with more smartphone devices than North America or Europe (United Nations, 2013). With this, the means of delivering Mark´s mission were absolutely clear.
As it goes, necessity is the mother of all invention, GraphQL was birthed as an internal Facebook service in 2013 because Facebook understood the burger combo vs actual demand dilemma.
They understood that they needed to deliver content and functionality on their platform as the individual user requires it - no more, no less.
After Facebook's proprietary and internal use of GraphQL, in 2015, they decided to share their technology under an Open Source license.
#GoodGuyFacebook.
As you can imagine, once set free into the Wild Wild West, GraphQL as a technology has benefited from the robust contributions of its ever growing community and, in my opinion, changing even the way we architect solutions to today's problems and thus think.
It would be great to hear from you and your ´burger´ stories!
How are you consuming your hotel content data? Via SOAP?
Your organisation´s availability/search call? Are you spending precious milliseconds removing the lettuce from the provider´s/platform´s RESTful response while your competitors are already serving their results to the client, sipping a milkshake.
Interested in seeing real GraphQL in action? Well, you´re in luck, young padawan!
Here’s an actual GraphQL burger playground for you, because you know what, it's your burger!
(also, here’s my codesandbox if you’d like to fiddle and learn)
Now that you’re full from the burger - how about you learn to search for hotels at industry leading API response speeds via TravelgateX’s GraphQL based HotelX ?!
Grab your free set of Travelgate´s HotelX API keys, pass them to your devs and send them to our drive-thru to grab the burger your organisation not only wants but deserves!:
Auth Header: "Authorization":"Apikey 8626cf56-e364-4fd1-4fe0-311e23ac6355"
CREDITS:
A super thanks to Chris Gannon (github: chrisgannon) for the burger graphics - it was truly fun learning to make it interactive in vanilla JS :)