filmov
tv
API Composition Pattern #designpatterns #softwaredevelopment #api #graphql #systemdesign #backend

Показать описание
API Composition Pattern : Why is it becoming an industry standard ?
Problem : A client needs data from mulitple services to fulfill a use case it’s trying to implement.
Simpler Solution : Client calls each service independently and processes responses
Problems:
Client should be aware of the different backend services and how to call them to fulfil the request (leads to coupling between client and backend services)
High Latency because of multiple network calls being made from client to get the data from different backend microservices,
Client also needs aggregate all fetched data then render it. Client should also handle errors and edge cases should the APIs fail to respond.
Better solution : Use API Composition Pattern.
API composition refers to the practice of combining multiple APIs to build a single new monolith API. This allows for:
All Data and services being accessed from a single query
One central catalog of all available data that all end client can look
Central management of the API ( for example, unified access control policies — becomes possible)
BENEFITS
Discoverability: Having all capabilities in a single api makes it easy to see what capabilities have been developed and who owns them.
Consistency: A single, governed api will ensure consistent objects that can be seamlessly shared between capabilities.
Flexibility to clients: Using API decouples data producers and consumers; the design allows updates without breaking clients. Federation and consistent governance allows producers to focus on their data without worrying about other data producers.
Efficient and Centralized Orchestration: In this approach, the central component coordinates the interactions between multiple APIs. It acts as an intermediary, receiving requests from clients, making requests to the relevant APIs, and aggregating or transforming the responses before sending them back to the client.
Rapid Development : Developers can quickly build new applications by leveraging existing APIs instead of writing code from scratch.
Promotes Reuse : By abstracting functionalities into APIs, organizations can reuse them across multiple applications, reducing redundancy and promoting consistency.
Unified Interface: This enables creating a unified interface for clients to interact with. Regardless of the underlying APIs being used, clients can interact with the composed API in a consistent manner.
Acts as a Middleware Layer: In a federated architecture, there’s often a middleware layer . This layer handles authentication, request routing, data transformation, error handling, and other cross-cutting concerns.
Dynamic Federation: In some cases, the composition of APIs might be dynamic, meaning that the federation logic adapts based on runtime conditions or client requests. This could involve selecting different APIs based on availability, performance, or user preferences.
#api #graphql #systemdesign #backend
Problem : A client needs data from mulitple services to fulfill a use case it’s trying to implement.
Simpler Solution : Client calls each service independently and processes responses
Problems:
Client should be aware of the different backend services and how to call them to fulfil the request (leads to coupling between client and backend services)
High Latency because of multiple network calls being made from client to get the data from different backend microservices,
Client also needs aggregate all fetched data then render it. Client should also handle errors and edge cases should the APIs fail to respond.
Better solution : Use API Composition Pattern.
API composition refers to the practice of combining multiple APIs to build a single new monolith API. This allows for:
All Data and services being accessed from a single query
One central catalog of all available data that all end client can look
Central management of the API ( for example, unified access control policies — becomes possible)
BENEFITS
Discoverability: Having all capabilities in a single api makes it easy to see what capabilities have been developed and who owns them.
Consistency: A single, governed api will ensure consistent objects that can be seamlessly shared between capabilities.
Flexibility to clients: Using API decouples data producers and consumers; the design allows updates without breaking clients. Federation and consistent governance allows producers to focus on their data without worrying about other data producers.
Efficient and Centralized Orchestration: In this approach, the central component coordinates the interactions between multiple APIs. It acts as an intermediary, receiving requests from clients, making requests to the relevant APIs, and aggregating or transforming the responses before sending them back to the client.
Rapid Development : Developers can quickly build new applications by leveraging existing APIs instead of writing code from scratch.
Promotes Reuse : By abstracting functionalities into APIs, organizations can reuse them across multiple applications, reducing redundancy and promoting consistency.
Unified Interface: This enables creating a unified interface for clients to interact with. Regardless of the underlying APIs being used, clients can interact with the composed API in a consistent manner.
Acts as a Middleware Layer: In a federated architecture, there’s often a middleware layer . This layer handles authentication, request routing, data transformation, error handling, and other cross-cutting concerns.
Dynamic Federation: In some cases, the composition of APIs might be dynamic, meaning that the federation logic adapts based on runtime conditions or client requests. This could involve selecting different APIs based on availability, performance, or user preferences.
#api #graphql #systemdesign #backend