What about GraphQL and how good is it? - Part 1
You may have heard about it, the Front-enders are talking about the next new thing, it is not React, but it is Facebook, it is GraphQL. The next big cheese in the industry and you should find out what it is and what it isn't. So, let's take a look at it.
What is it?
So, what is this big new potato? It is a query language to put as a layer on top of your APIs. It enables the front-end to query and ask for exactly what they need. Imagine that you take all your APIs and make them to one big model and the developer can ask for only the properties he needs. That is what it is. Won't that generate a lot of requests? Well, no not with GraphQL at least. You can ask for multiple resources in one request. No types? Yes, you create a schema with types. In short, this is what it is. For a complete introduction go to the GraphQL site
How an architecture with GraphQL can look like.
I am actually writing this since I went to a meetup and listened to session about it, a good friend and colleague Erik (give him a shout out and check out his React libs react-breakpoints that resolves the problem that CSS media queries alone could not solve, cra-ssr-middleware A non-compromising way to enable server-side rendering on create-react-app without ejecting.) was talking about it and went to a meetup about it.
The meetup presentation was impressing, it shows potential but also some areas I believe can be quite hard to work with when things changes. They also had a professor in databases, presenting his research on GraphQL and his findings which I will cover later, but it was impressing, so I need to try it out. Let's make a challenge of it. Let test it out. Let see how good it really is.
So here we go, to test it we need some endpoints, and we also need a server and a client. I'm going for the Apollo client since it seems to be the most popular choice and the Apollo server too.
Let's add some APIs and some backend with MongoDB and SQL. Let's make them in at least 2 or 3 different languages since its one of the strengths. Let's push it with some testing tools like locust to put some load on it and also let’s test some edge cases to see how performant it is. However, first let's start with the first part, hooking the backend stuff up, and let's see how it goes.
To not make a monster post that never gets done let me start with the first part and then continue, hey its cool to do series these days!
So, what's the story? Let's say we want a system for students. Let's say a student can go to different schools. Let's say every student can go courses, and that every student can get grades in each class. Every student can then have a profile and friends.
Let's start with a python API as a backend for the schools’ API.
.NET Core 2.1 API
Let's do the students API in .NET Core with a SQL database with Entity Framework
Node JS API
Let's do a NodeJS backend for the grade’s API
C++ API to be a bit hardcore
Let's do a C++ API because I think it’s a bit cool hehe.
Now let’s start with the Python API in the second part.