top of page
  • Writer's picturePriyanka Palshetkar

Exploring GraphQL as an alternative to REST API - Part 4

Let’s explore GraphQL from an architectural point of view.


This is the simplest architecture in which we have our client which interacts with a single GraphQL endpoint connected to a single database.


But GraphQL is very versatile. We can even have architectures integrated with our existing systems where we connect a GraphQL endpoint to our legacy system, and even to another micro service or a third party payment API, and even more.

And why stop at that? We can even have a hybrid approach where we merge the previous two architectures and make an even complex integrated system like this one.

And how is all this possible? It’s because of GraphQL resolver functions. So under the hood, each of our field in a query has a resolver function attached to it. So when we send a query like this one where we want a list of appetizers with their name, price and description, what we are doing under the hood is calling a set of resolver functions. All these functions are resolved to return data on the field associated with it. And at the end GraphQL packs all this data back in the format in which it was asked in the query and sends it back to us. Because it is a set of resolver functions which we can define to get the data we want, GraphQL is flexible and database agnostic.

Continued in Part 5

15 views0 comments

Comments


bottom of page