SchemaLess APIs
This is what someone could write on a Blog or speak on a conference about in a a few years from now. Because today, a new type of protocol is getting popular. These protocols define schema and query languages. The most famous are GraphQL and GRPC. Today we also live in a time, where native apps are getting more popular again. Content is inside the apps and apps just let you search for content within the own catalog. Hoping you will never leave there ecosystem. We are in a time of online schools, code academies and video lectures. These classes need systems technology that is big and complex. So that the student will keep hooked and learn more, and consume more material about the next cool tech. Within this environment of today, someone is going to decide, I want to become a software engineer. He will make apps, deploy them to cloud, use a bunch of huge frameworks, angular, loopback, … Then he will get to an idea, that fetching data should be much simpler. He is first going to write an article like to following:
Hi, application development is easier then ever. Today we have a strong schema and strongly typed query languages. Hello, I am So and So, and I develop applications since many years. I want to talk with you about APIs. When we want to access data from our client side, we can easily send a query from client to our app and get the expected response. Lets say, we develop a shop. On the Front View we show the user our 10 most popular products from the last 10 days. Then the user can navigate to the tech products and see some more properties for each product. The user tap on a product and we query the details.
At this point, the frontend developer had to write already three queries, just to get he same type of information: Product information. We are writing 3 queries and maintain a cache for each of them. When the data updated, we have to make sure that the caches for each query get reset. The result is, as you know a very nice application.
I believe the app could be developed more easily. How would it be, if the frontend just ask for the most popular products, and get all the data it needs? What if the frontend just access products and limits the result by category? what if we could fetch the product detail information without specifying all the fields we want, only providing its id and the server just provide all the information the application needs?
Here is what I propose: like in a graph, we address everything with a path. For example like this:
1 | /products/popular |
We could even mutate the database by sending JSON to a path.
1 | CREATE /products |
When we query the product details, we can the object information to the Client.
…
Now, this might sound impossible to you: We could even access the data from an other app, with within our app. by specifying the applications name.
1 | GET otherapplication.com/products |
I am calling this the Unified Resource Identifier. What do you think. Lets do it, it will be so much easier.