Member-only story
REST is easy with GraphQL as a sidekick. Two are better than one.
There is a constant debate between REST and GraphQL architectural patterns. Tech blogs are littered with comparisons.
The Most pragmatic and fit-for-purpose approach is to leverage their strengths and not worry about which option is superior. I am not dogmatic about these options. GitHub for example supports both APIs.
I am generally inclined to do more with REST (given the ecosystem and security support) and manage concerns such as:
- Need for multiple BFF (Backend For Frontend needs) / Bandwidth
- over/under fetching
- type safety
by leveraging Typescript, practical DDD, and OWASP security practices.
However, there is an option of “have your cake and eat it as well!”!
Before we dig into the code, let me review some solution concepts.
- Layer Cake
- Advantages of this hybrid approach
- Disadvantages of this hybrid approach
Layer Cake
In this proposed approach, we will build a single unified backend or Back-end for a Front-end pattern if you are integrating with domain services or enterprise services including Authorization Server.
You will also integrate with a single service and repository layer for your application or a product or platform.