Elevating your API strategy with Hasura
In today’s digital landscape, APIs (Application Programming Interfaces) play a crucial role in enabling seamless integration, data exchange, and collaboration across various systems and applications. As organizations strive to build robust API strategies, they often turn to API gateway tools to effectively manage and secure their APIs.
In this blog post, we will explore the powerful combination of Hasura, a cutting-edge GraphQL engine, with API gateway tools. While Hasura itself offers comprehensive API management capabilities, we will focus on how existing API gateway tools can complement and enhance Hasura, empowering developers and organizations to unlock the full potential of their API strategies.
Rather than viewing Hasura as a replacement for API gateway tools, we will highlight the incremental adoption approach, showcasing how Hasura seamlessly integrates with established API gateway platforms such as Apigee, MuleSoft, and more. By leveraging the unique features and strengths of both Hasura and API gateway tools, organizations can optimize their API strategies, improve time to market, enhance security, and drive monetization opportunities.
We will delve into different scenarios where Hasura can be utilized alongside API gateway tools to address specific challenges and unlock key benefits. From API monetization and metering to traffic routing, TLS termination, load balancing, preventing bot attacks, and catering to custom routing use cases, we will explore the breadth of possibilities when combining Hasura with API gateway tools.
Whether you are a developer, a DevOps engineer, or a technology leader, this post provides valuable insights into how Hasura enhances your existing API gateway infrastructure, enables rapid development, streamlines monetization strategies, and accelerates time to revenue. So let’s dive in and discover the immense value of leveraging Hasura alongside API gateway tools to supercharge your API strategy.
1. API generation for the API gateway
One of the key advantages of using Hasura in conjunction with other API gateway tools is its ability to directly generate APIs. Hasura acts as a GraphQL engine that sits between your applications and various data sources, allowing you to expose GraphQL and REST APIs that seamlessly connect to your backend services. By leveraging Hasura’s automatic schema generation and real-time subscriptions, you can simplify the process of creating APIs for the API gateway.
Typically, API gateway tools require explicit configuration and setup for each API endpoint. However, with Hasura, you can generate a comprehensive GraphQL API that encompasses all the required data and functionality from your backend systems. This eliminates the need for manual configuration of individual APIs in the gateway, streamlining the development process and reducing maintenance overhead.
By utilizing Hasura’s API generation capabilities, you can seamlessly integrate it with the API gateway of your choice. The API gateway can then leverage the generated APIs to manage traffic, apply security policies, and implement additional features specific to your API strategy. This combination allows you to leverage the power of GraphQL and the advanced capabilities of the API gateway, resulting in a more efficient and flexible API ecosystem.
Use Case
API generation with Hasura for API gateway
Architecture
In this architecture, the API gateway serves as the entry point for incoming requests. It handles request routing, security, and other gateway-specific features. When a request is received, the API gateway routes it to Hasura.
Hasura acts as a GraphQL engine that generates APIs based on the underlying data sources, which can include various backend services, databases, or microservices. It automatically generates the GraphQL schema and exposes a comprehensive API that encompasses the required data and functionality from the backend systems.
The API gateway can then leverage these generated APIs provided by Hasura to manage traffic, apply security policies, and implement additional features specific to your API strategy. It serves as the intermediary between client requests and the Hasura-powered APIs.
Hasura’s ability to generate APIs for the API gateway simplifies the process of API configuration and maintenance. Instead of manually configuring individual APIs in the gateway, you can rely on Hasura to dynamically generate the APIs based on the underlying data sources.
By combining Hasura’s GraphQL generation capabilities with the features provided by the API gateway, you can create a powerful API ecosystem that seamlessly integrates different backend services while taking advantage of the gateway’s advanced functionalities.
2. API monetization, metering, and time to revenue
When considering Hasura in conjunction with other API gateway tools, one of the key advantages is its ability to enhance API monetization, and metering, and significantly reduce the time to revenue. By leveraging Hasura’s GraphQL capabilities alongside the monetization features of API gateway tools like Apigee or MuleSoft, you can expedite the process of generating revenue from your APIs.
Hasura plays a vital role in this architecture by generating comprehensive GraphQL APIs that seamlessly integrate with your backend services. These APIs serve as the foundation for your monetization strategy, allowing you to effectively monetize your APIs.
By combining Hasura’s API generation with the monetization features provided by API gateway tools, you can quickly implement pricing models, usage-based billing, subscription plans, and access control mechanisms. This enables you to efficiently monetize your APIs and start rapidly generating revenue.
The value of Hasura, from a monetization perspective, lies in its ability to significantly reduce time to revenue. With Hasura, you can build products and services up to 10 times faster compared to traditional approaches. Once your APIs are built using Hasura, you can seamlessly integrate them with API gateway tools like Apigee or MuleSoft, which offer robust monetization features.
The API gateway tools provide capabilities such as usage tracking, metering, analytics, and reporting, enabling you to gain deep insights into API usage patterns and trends. These insights are valuable for understanding customer behavior, optimizing pricing strategies, and making data-driven business decisions.
By leveraging the combined power of Hasura and API gateway tools, you can accelerate your time to market and revenue. Hasura’s rapid API generation capabilities, coupled with the monetization features of the API gateway tools, allow you to roll out your products and services quickly, capitalize on market opportunities, and start generating revenue in a shorter timeframe.
Use Case
Implementing monetization and metering capabilities for APIs to generate revenue based on usage.
Architecture
The existing API gateway tool can handle API monetization and metering, while Hasura serves as the backend GraphQL layer, providing data aggregation and composition. Clients interact with the API gateway, which enforces access control, rate limiting, and metering policies before routing the requests to the Hasura GraphQL API.
In this architecture, the existing API gateway acts as the entry point for API requests. It handles the initial request processing, security, and rate-limiting aspects. The API gateway then forwards the requests to Hasura’s GraphQL Engine.
Hasura serves as the central GraphQL layer, providing a unified API interface for data sources. It integrates with various data sources, such as databases, microservices, or external APIs, to aggregate and compose the necessary data. Hasura retrieves the requested data and returns it to the API gateway, which then responds to the client with the aggregated data.
By integrating Hasura with the existing API gateway, organizations can leverage the power of GraphQL and enhance their API strategy. Hasura simplifies data composition, reduces the complexity of handling multiple data sources, and provides a consistent API interface. This architecture enables incremental adoption of Hasura within the existing API strategy, allowing organizations to take advantage of GraphQL capabilities without completely replacing their current API gateway solution.
The emphasis on time to revenue underscores the importance of speed and agility in today’s competitive landscape. By leveraging Hasura’s efficiency and the monetization features of API gateway tools, you can streamline your API strategy, reduce time-to-market barriers, and achieve faster returns on your API investments.
3. API traffic routing via policies
API gateway tools excel at managing API traffic and routing requests to the appropriate backend services based on defined policies. However, in some cases, more complex routing requirements may arise, necessitating the need for additional capabilities. Hasura can seamlessly integrate within this architecture to enhance traffic routing.
By placing Hasura behind the API gateway, you can leverage the gateway’s routing capabilities, such as route matching, traffic splitting, or URL rewriting. Hasura’s GraphQL engine becomes one of the backend services that the API gateway routes requests to. This allows you to take advantage of the advanced routing features of the API gateway while benefiting from Hasura’s data aggregation and composition capabilities.
In this architecture, the API gateway acts as the entry point for incoming requests, applies routing policies based on criteria such as request headers, paths, or query parameters, and directs the requests to the appropriate backend services, including Hasura. Hasura then retrieves and processes the required data from the connected data sources and returns the response to the API gateway, which forwards it to the client.
By combining Hasura with an API gateway’s powerful routing capabilities, you can achieve more flexible and granular control over API traffic routing, enabling you to implement complex routing scenarios and meet specific business requirements.
Use Case
Routing API traffic based on specific policies such as user roles, geographic location, or request attributes.
Architecture
The API gateway tool handles the traffic routing based on policies, while Hasura acts as the backend GraphQL layer that provides unified access to data sources. Clients communicate with the API gateway, which directs the requests to the appropriate Hasura endpoints based on the defined policies.
In this architecture, the existing API gateway is responsible for initial request processing, security enforcement, and other gateway-specific functionalities. The API gateway forwards the requests to Hasura’s GraphQL engine.
Hasura serves as the GraphQL layer, providing a unified API interface to interact with various data sources. It integrates with data sources, such as databases and microservices, to aggregate and compose the necessary data. Hasura then applies policies defined by the API gateway to perform API traffic routing based on factors like user roles, geographic location, or request attributes.
The policies determine how the requests are routed to specific APIs or data sources within Hasura. Hasura evaluates the policies and directs the requests to the appropriate resources, ensuring that the traffic follows the defined routing rules.
By integrating Hasura with the existing API gateway, organizations can leverage the powerful routing capabilities of the gateway and the data aggregation capabilities of Hasura. This architecture enables fine-grained control over API traffic and provides flexibility in defining routing rules based on various factors.
4. TLS termination
When it comes to secure communication between clients and backend services, TLS termination is essential. While API gateway tools excel at handling TLS termination, Hasura can seamlessly integrate within this architecture.
Hasura’s GraphQL engine can be placed behind the API gateway, where the gateway handles TLS termination and routes the requests to Hasura over an encrypted connection. This ensures secure communication while allowing Hasura to focus on data aggregation and composition.
Use Case
Handling TLS termination for secure communication between clients and backend services.
Architecture
The existing API gateway tool can handle TLS termination, while Hasura focuses on data aggregation and composition. Clients establish secure connections with the API gateway, which terminates TLS and proxies the requests to the Hasura GraphQL API.
In this architecture, the existing API gateway is responsible for handling TLS termination and routing for secure communication between clients and backend services. The API gateway acts as the entry point for encrypted requests.
Hasura’s GraphQL engine sits behind the API gateway and handles data aggregation and composition. It receives requests from the API gateway over an encrypted connection.
The API gateway is responsible for terminating the TLS connection, ensuring secure communication between the clients and the gateway. It also handles routing the requests to the appropriate Hasura GraphQL endpoints based on the defined routing rules.
By integrating Hasura with the existing API gateway, organizations can leverage the secure communication capabilities provided by the gateway while benefiting from Hasura’s powerful GraphQL engine for data aggregation and composition.
5. Load balancing / reverse proxy(nginx-like use cases)
In high-traffic scenarios, load balancing and reverse proxy capabilities are crucial for distributing requests and achieving scalability. API gateway tools often offer these features, and Hasura can complement them effectively.
By placing Hasura behind the load balancer or reverse proxy, you can leverage the load-balancing algorithms and routing capabilities provided by the gateway. The gateway distributes the incoming requests to multiple instances of Hasura, ensuring optimal performance and high availability.
Use Case
Distributing incoming API requests across multiple backend instances to ensure scalability and high availability.
Architecture
The existing API gateway tool performs load balancing and acts as a reverse proxy, distributing requests among backend services. Hasura, as the GraphQL layer, connects to the backend instances managed by the API gateway, ensuring seamless data retrieval and composition for clients.
In this architecture, a load balancer is responsible for distributing incoming API requests across multiple instances to ensure scalability and high availability.
The load balancer receives the incoming requests and forwards them to a reverse proxy, which acts as an intermediary between the clients and the backend services.
Hasura’s GraphQL engine sits behind the reverse proxy and serves as the centralized GraphQL layer. It connects to the data sources, such as databases and microservices, to retrieve and aggregate the necessary data.
The reverse proxy receives the incoming requests and routes them to the appropriate Hasura GraphQL endpoint based on load-balancing algorithms or other configuration rules. Hasura then handles the data retrieval and composition, returning the aggregated data to the reverse proxy, which in turn responds to the clients.
By integrating Hasura with the load balancer and reverse proxy, organizations can achieve scalable and high-performing APIs. The load balancer ensures the efficient distribution of requests, while the reverse proxy handles routing and load balancing at the network level. Hasura focuses on data aggregation and composition, providing a powerful GraphQL engine for seamless interaction with data sources.
6. Preventing bot attacks and unusual activity
In the ever-evolving landscape of cybersecurity threats, organizations need robust measures to protect their APIs from malicious activities, including bot attacks and unusual traffic patterns. While API gateways typically offer some security features, additional tools like Imperva are often utilized for specialized bot mitigation capabilities.
Hasura, when combined with existing API gateway tools, can augment the security measures in place by providing an additional layer of protection against bot attacks and unusual activity. While it is true that some API gateway tools may not offer comprehensive bot mitigation features, the combination of Hasura and specialized security tools delivers a robust defense strategy.
By leveraging Hasura as an intermediate layer, you can implement custom security measures, such as rate limiting, request validation, and IP blocking, to identify and mitigate malicious bot traffic. Hasura also provides security features against these use cases (you can have a look here).
By combining the strengths of Hasura and specialized security tools, you can establish a comprehensive defense against bot attacks and unusual activity. Hasura’s ability to integrate with various security solutions allows you to customize and strengthen your API security posture, ensuring the integrity and availability of your APIs.
It is worth noting that while API gateways may not provide extensive bot mitigation capabilities out of the box, the integration of Hasura with specialized security tools can help you achieve a robust and comprehensive security strategy. By incorporating Hasura in this architecture, you can leverage its flexibility, scalability, and ability to integrate with best-in-class security solutions, enhancing your overall API security posture.
Use Case
Protecting APIs from malicious bots, DDoS attacks, and other unusual activities.
Architecture
The API gateway tool specializes in bot detection, DDoS mitigation, and anomaly detection, providing a robust defense mechanism. Hasura complements this by serving as the GraphQL layer, where clients interact securely with the API gateway’s protected endpoints.
In this architecture, a bot detection and security system is responsible for identifying and preventing bot attacks and unusual activities.
Hasura’s GraphQL engine sits behind the bot detection and security system and serves as the centralized GraphQL layer. It connects to the data sources, such as databases and microservices, to retrieve and aggregate the necessary data.
The bot detection and security system monitors incoming API requests for suspicious patterns, unusual activity, or known bot signatures. It applies security measures to identify and block potential bot attacks, ensuring the integrity and availability of the API.
Once the requests pass through the bot detection and security system, they are forwarded to Hasura. Hasura retrieves the requested data from the data sources, performs necessary data transformations or aggregations, and returns the response to the client.
By integrating Hasura with a robust bot detection and security system, organizations can enhance the protection of their APIs against bot attacks and unusual activities. Hasura’s GraphQL engine ensures seamless data retrieval and aggregation, while the security system adds an additional layer of protection to safeguard the API infrastructure.
7. Custom routing use cases
In some scenarios, you may have specific routing requirements, such as hosting the GraphQL endpoint on a different URL or using custom domains. API gateway tools can facilitate these custom routing needs, and Hasura can seamlessly fit into such architectures.
By integrating Hasura with an API gateway that supports custom routing configurations, you can route requests to the appropriate Hasura GraphQL endpoint or define custom domains for different parts of your API. Hasura’s GraphQL engine handles data retrieval and composition, while the gateway ensures the requests are directed correctly based on the custom routing rules.
Use Case
Configuring custom routing for specific GraphQL endpoints or utilizing custom domains.
Architecture
The API gateway tool handles the routing configurations, including mapping custom domains or setting up endpoint URLs. Hasura seamlessly integrates with these custom routes, providing the necessary GraphQL functionality and data aggregation as requested by the clients.
In this architecture, a custom routing layer is responsible for directing API requests to specific endpoints or services based on custom routing rules.
Hasura’s GraphQL engine sits behind the custom routing layer and serves as the centralized GraphQL layer. It connects to the data sources, such as databases and microservices, to retrieve and aggregate the necessary data.
The custom routing layer receives the incoming API requests and evaluates custom routing rules. Based on these rules, the requests are directed to the appropriate Hasura GraphQL endpoint or to other services that may be integrated within the routing layer.
Once the requests reach Hasura, it handles the data retrieval, composition, and any necessary transformations, returning the response to the custom routing layer.
Additionally, the custom routing layer can also handle custom domains, allowing API requests to be routed to specific domains or subdomains based on configuration.
By integrating Hasura with a custom routing layer, organizations can achieve fine-grained control over request routing and customize the behavior of their API endpoints. Hasura’s GraphQL engine handles the data aggregation and composition, while the custom routing layer adds an additional layer of flexibility and customization to the API architecture.
Conclusion
Integrating Hasura with existing API gateway tools can enhance their capabilities and provide additional value in various use cases. Whether it’s API monetization, traffic routing, TLS termination, load balancing, security, or custom routing, Hasura acts as a powerful GraphQL engine that complements the functionalities of API gateway tools, resulting in a more comprehensive and efficient API management solution.
While API gateway tools provide essential functionalities for managing, securing, and optimizing APIs, integrating Hasura within your API strategy can bring added benefits. Whether leveraging Hasura’s GraphQL engine for data aggregation, complementing existing gateway features, or accommodating custom routing needs, combining Hasura with other API gateway tools can enhance your overall API architecture and deliver a seamless developer and user experience.
By assessing your needs, and evaluating the capabilities of both Hasura and the API gateway tools, you can design an API strategy that maximizes the strengths of each component.
Leveraging the strengths of both Hasura and API gateway tools, enterprises can create robust, scalable, and secure APIs that cater to their specific requirements, while enabling incremental adoption and enhancement of their existing API strategies.
Sign up now for Hasura Cloud to try these out!
Originally published at https://hasura.io on June 9, 2023.
Subscribe to my newsletter
Read articles from Community Hasura directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by