GraphQL APIs

GraphQL provides a more flexible and alternative approach for data-intensive operations in the API Management domain. This will be beneficial for querying and retrieving data in optimized forms. With this approach, it is possible to make applications more efficient.

Here, we will look at exposing GraphQL services as managed APIs to build an API ecosystem that will unlock a whole new set of benefits.

Build Better Customer Experiences with GraphQL

Why Should We Use GraphQL?

In order to be cost-effective and increase profit margins, it is vital for a tech enterprise to keep an eye on the latest innovations and technologies and adopt them in the firm’s solutions to solve existing problems in an efficient way. In the tech solutions arena, various activities are happening around adopting GraphQL. While there are clear technical benefits to using GraphQL, from a business perspective, supporting GraphQL helps to attract new developer communities and create more responsive resource-conscious applications, which, in turn, helps to expand the business.

Similar to understanding the technical and business benefits of GraphQL, understanding the monetization and management aspects of GraphQL is equally important. This is what we are going to discuss in this article.

The Importance of Adopting GraphQL

The use of GraphQL has grown exponentially following the release of its open-source version. Thereafter, many technology-based businesses adjusted to this new phenomenon. The key explanation for this was that GraphQL is more efficient in API-based applications. This is one of the main reasons for an organization to adopt GraphQL. Furthermore, this also helps the firm to expand its business as there are many organizations and developers that have started using GraphQL.

When we consider traditional REST APIs, over the past few years, the API landscape has changed radically. And there are some factors in particular that have questioned the way REST APIs are built [2].

  • The use of mobile devices necessitates effective data loading

Facebook created GraphQL primarily owing to increased smartphone use, low-powered devices, and poor networks. GraphQL minimizes the amount of data that needs to be transmitted across the network, and thus significantly improves applications that run under these conditions.

  • The variety of various frontend applications and platforms

The diverse landscape of frontend frameworks and platforms running client applications makes it challenging to build and maintain an API that would fit everyone's requirements. With GraphQL, each client can accurately access the data they require. This is important because today’s customers demand access to their data and services whenever they want—using any device they prefer.

  • Rapid development and expectations for the quick development of features

Following rapid changes in the marketplace, the need for accelerated development has increased. It is vital to keep up with the latest customer requirements (for the betterment of the business). In order to minimize the effort and cost of iterative development, service providers have to look for better alternatives such as GraphQL, because adopting traditional methodologies to facilitate today’s requirements will surely become an overhead to the business.

GraphQL and API Management

How GraphQL works

API management has been a key driver for digital transformation efforts. Today, it is difficult to find an enterprise that does not use APIs to perform business operations. APIs can be used in a wide range of applications and sectors—including travel, e-commerce, medical, banking, and aviation. As APIs have become the foundation of many digitally transformed companies, in recent years, API management has become a trillion-dollar industry.

As technological businesses have started to adopt new technologies such as GraphQL, it is time to combine the popularity of APIs with trending technologies to develop systems and facilitate modern business and development needs.

When we consider API management concepts, most of the concepts used in traditional REST-based API management are applicable to GraphQL-based API management as well. However, there are some differences in concepts like limiting API calls per resource and security at API resource level.

Using GraphQL APIs might not allow the business to fine-grain quality of service exactly as same as REST APIs as there can be complex scenarios in a single GraphQL API request. For example, it is a straightforward process to control traffic in a business that uses REST APIs, whereas a business that uses GraphQL might need some modifications based on the use case. Having said that, there can be different ways to fine-grain the quality of service for GraphQL APIs. For example, applying subscriptions considering the lowest limit out of the operations coming into the request. Moreover, some can consider different attributes to throttle GraphQL API requests such as query complexity and depth. This will be useful for offering the quality of service (QoS) for rate limiting.

Similarly, when we consider applying security for each operation, GraphQL APIs will differ from traditional REST APIs as GraphQL API requests can have more than one operation. This also can be tackled by having different rulings applied.

Secured GraphQL

Apart from the above points, monetization plays a major role in the API management space, where it helps to generate revenue from the APIs. In particular, monetizing GraphQL is also more important to generate profits as it has become one of the latest trends that developers and businesses have started to adapt. When we consider GraphQL as a revenue-generation source, we can define the subscription plans based on the query complexity of the request.

Here, different pricing plans can be defined when offering service to consumers. Earning potential can be maximized with the optimal pricing strategy. At the same time, the same service can be exposed to multiple audiences using different pricing plans.

Monetizing GraphQL

This will make sure that the service provider is able to generate revenue from GraphQL APIs with a set of suitable pricing plans. Also, this will be beneficial to the users as they can choose the best possible plan(s) based on the budget they have.

Conclusion

When you select an API management solution for your organization, it is important to pay close attention to the points that we discussed in this article on why having GraphQL is important. The solution should allow you to have and expose GraphQL APIs while adhering to the API management concepts like rate limiting, API security, and monetization, which will ensure business growth.

WSO2 API Manager is a complete API management solution, which includes support for GraphQL, and most importantly adheres to API management concepts. Find out more about how GraphQL APIs can be exposed using WSO2 API Manager.

[1] - https://graphql.org/

[2] - https://www.howtographql.com/basics/0-introduction/

Meeting Modern Business Needs with GraphQL

What is GraphQL?

GraphQL is a query language (for APIs) and runtime to satisfy certain queries for your current data. GraphQL offers a comprehensive and comprehensible description of the data in your API, gives users the ability to demand exactly what they need (and nothing more), allows APIs to be easily modified over time, and provides effective development tools [1].

GraphQL is a new, evolving query language developed by Facebook (primarily for the company’s mobile apps). Initially used for web-based applications, it has gained popularity over the past couple of years in the API management domain owing to its unique advantages. The following diagram shows how GraphQL architecture works.

How GraphQL works

Why Use GraphQL?

One major advantage of having GraphQL in place is that application developers will have the opportunity to reduce back and forth communication, which results in reducing network calls. For example, if we take a look at REST API architecture, a client would need to make several calls to get a particular flow of functionality to work.

REST architecture

On the other hand, GraphQL architecture has a completely different flow, where there will only be a single request object passed to a single endpoint. Then, according to the query object, the functions will be called and the response will be returned.

GraphQL architecture

This also makes the lives of application developers easier as they do not have to worry about multiple endpoints, headers, and status codes. Apart from the above advantages, there are some other advantages such as the ease in which to build the solution and being able to have fine-grained or composite responses.

Architecture Styles or Web Patterns of Communication

When it comes to architecture or web patterns that GraphQL can be incorporated into, there are multiple patterns that we can think of. We will discuss two patterns here.

Composite Pattern

The first one is using GraphQL in a composite pattern. For instance, we can have a GraphQL API that will aggregate data from multiple sources, such as a REST API or database stored procedures (T-SQL, PL-SQL), and build the response. The following diagram illustrates this.

Composite Pattern

Façade Pattern

The next pattern would be to use GraphQL in a facade pattern, where it would use a single query to return some data that is needed for a single use case. For example, in an analytics dashboard, there is a widget that will have some data. In order to populate this widget, and if a traditional REST API is used directly, it would need to make several calls. If we can use GraphQL in a facade pattern, this can be achieved using a single call to the GraphQL API, where it will composite all the calls to the REST API that is needed to populate the widget.

Facade Pattern

The composite pattern is also kind of a facade pattern that uses different sources to get the data for a particular use case

In a similar fashion, the GraphQL concept can be added into several architectural and design patterns as per the need.

Conclusion

The right API management solution is critical for business success. When it comes to the selection process, it is vital to take a closer look at the points we have discussed in this article. The solution should be able to expose GraphQL APIs, which adhere to the GraphQL architecture, and also have the same support for traditional REST APIs.

It needs to be highlighted that traditional API management solutions might not be suitable or support the GraphQL style of communication. This is the reason why a modern API management solution such as WSO2 API Manager is required. It treats GraphQL characteristics as first-class features to reap the benefits of API management on top of the advantages that GraphQL provides.

[1] - https://graphql.org/

Exposing GraphQL Services as Managed APIs with QoS

Why is GraphQL Important?

GraphQL Logo

GraphQL is a new emerging query language developed by Facebook for mobile applications. It was initially used for web-based APIs, and, over the past few years, has gained popularity in the API management arena as well. The language’s unique advantages have been the main catalyst behind its popularity.

These unique advantages are beneficial for API developers as they make their lives easier when working with modern API ecosystems. This post focuses on those advantages and how APIs can be used to further enhance the overall experience for both developers and end-users.

After releasing GraphQL’s open-source version, usage has grown exponentially. Several technology-based companies—such as GitHub, Coursera, PayPal, Shopify, and Yelp—have adopted this new trend. The main reason for this is that GraphQL can be used in API-based applications in a more developer-friendly and efficient manner. The data model for the GraphQL specification is represented using the Schema Definition Language (SDL). Here, it will specify the data types and relationships among those data. This well-structured SDL makes it easier for developers.

API Management for GraphQL

API management is key for digital transformation. Today, it is hard to find a company that does not use APIs to perform and enhance business operations. APIs can be seen in a wide range of applications and industries such as transport, e-commerce, medical, banking, and even in the airline industry.

Since APIs have become the heart of many digitally transformed businesses, API management has become a billion-dollar industry in recent years. Owing to increasing demand for APIs, the ability to design robust API-based solutions has become a “must-have” skill for developers.

For a significant amount of time, APIs have been based on traditional REST and SOAP-based protocols. These technologies have been there for more than a decade, and, now owing to the growing popularity of APIs, it is time to think of adapting novel technologies and trends to cater to modern business and software development requirements.

GraphQL vs. REST
GraphQL vs. REST

Now, the time has come to combine the popularity of APIs with trending technologies such as GraphQL to develop systems to facilitate modern development and business needs.

When it comes to using GraphQL with APIs, it will be beneficial in many ways. The final solution will have a well-structured and well-defined definition. This will enhance the developer experience to create, build, and manage fully functional API based applications using GraphQL.

On the other hand, applying the quality of service (QoS) is a huge advantage. These QoS aspects are a must when it comes to exposing digital services in a digitally transformed business environment. Moreover, the ease of managing these digital services is also another benefit. In other words, a GraphQL-based API can be designed, developed, and maintained by a set of people in the organization. This capability unlocks the possibility to have segregation of duties in the system.

Last but not least, security is a major concern in any application. Having a robust, secure API management system to expose GraphQL-based APIs will make sure that everyone can use the solution without worrying about information theft.

GraphQL for Development

Multiple benefits can be found when using GraphQL in the API management space.

Here are some major benefits for developers and system administrators. These benefits will make lives easier for API developers and application developers. At the same time, end-users will be able to have a better user experience.

When GraphQL is used, it makes sure to retrieve only the required data (for a given request), nothing more, and nothing less. In other words, this can be considered as zero over-fetching or zero under-fetching. This makes sure that the requests are served in the most efficient way (by serving the information needed to complete the operation).

Another benefit of GraphQL is that it enables API developers to expose data using a single endpoint. Therefore, developers can retrieve data using a single API call. Also, since GraphQL supports fetching data by using a“no more over-fetching or under-fetching” method, this is much easier than traditional protocols like REST or SOAP. In REST (or SOAP), it may serve data via multiple endpoints, but in GraphQL APIs, this is not needed.

When using GraphQL-based APIs, it is possible for front-end and back-end developers to work independently. If the schema is defined, this can be done easily because both parties can continue their work using mock data structures.

Parallel working

GraphQL is a new emerging query language developed by Facebook for mobile applications. It was initially used for web-based APIs, and, over the past few years, has gained popularity in the API management arena as well. The language’s unique advantages have been the main catalyst behind its popularity.

Multiple versioning

Multiple versions of the same API would need to be maintained in a typical API management solution. This is owing to the continuous improvements done to the API (or the service). Introducing new changes will force API owners to create a new version of the same API because the implementation is going to change significantly. This will cause misbehaviors in existing applications. However, with GraphQL, there will be a ‘versionless’ approach. Since GraphQL APIs return only the required amount of data, applications will function normally without any hassle. If any additional data is needed, it is a matter of changing the query, not the API. Maintaining the API becomes much easier.

API documentation is a lifesaver for developers when it comes to developing information systems. From time to time, new changes are introduced to APIs. API documentation needs to be updated along with those changes. In traditional REST API-based development efforts, this takes a considerable amount of time. But, with GraphQL, it is easier to auto-generate API documentation automatically with the GraphiQL tool. There are many resources available to get familiar with this tool and provides significant advantages for developers.

Sometimes, GraphQL-based APIs are faster than traditional REST APIs because of the reduced number of API calls. This will become an advantage when developing applications based on APIs. This is very useful in data fetching networks. The reason is GraphQL-based APIs can fetch the required data in a single call. If a traditional mechanism (like REST) is used, then, there might be multiple calls needed. Eventually, it might increase the complexity of the solutions.

QoS for GraphQL APIs

When new technologies arise, the industry should adapt to those to keep the business running. This is common for the API management space as well. GraphQL-based APIs unlock a number of benefits to cater to these modern business requirements. At the same time, it is necessary to make sure the required quality of service (QoS) is also there.

When GraphQL APIs are exposed to a well-established API management system, the possibilities are endless. This section contains some “must-have” QoS for GraphQL based APIs to build a fully functional, easily manageable API management ecosystem.

If we get started from the inception phase of an API, the API management solution should provide facilities to create and manage APIs with user-friendly interfaces. An API is a digital contract; it should be well-defined. The same principle applies to GraphQL APIs as well. If that can be achieved easily, then both the benefits of the API management and GraphQL can be enjoyed.

Once the APIs are developed, then, users should be able to discover those services (i.e., APIs) in an easier manner. This is where a portal becomes a lifesaver. By listing all the GraphQL APIs inside a fully functional portal, users can browse, locate, evaluate, subscribe, and consume those APIs with ease. Based on the need, there will be community features such as a rating system to further enhance the user experience.

API Portal

Information security is one of the top priorities in any application. Hence, it is a must to enforce strong and reliable security measures to protect the system from attacks. Otherwise, users cannot rely on the system, and this will negatively affect the growth of the business in the long run.

To prevent these drawbacks and to make the system secure, it is key to enforce various authentication and authorization mechanisms. This can vary from using basic authentication to AI-based advanced security algorithms. Security features such as mutual authentication play a major role in protecting the system from attackers. This will enhance the security of GraphQL-based APIs (with the help of the API management system).

Authentication vs. authorization

In the API management space, it is very important to include well-structured service level agreements (SLAs). It should provide a mechanism to associate SLAs for APIs. These SLAs will make sure that users cannot abuse the system even if they are authenticated. A major benefit of using SLA-based throttling includes making an API, application, or resource available to a consumer at different levels of service. At the same time, it helps to protect APIs from common types of security attacks and regulates traffic according to infrastructure availability.

Representing rate limiting

Rate limiting and managing incoming traffic is important in real-world deployments. This is somewhat aligned with scalability. This will make sure that the system is not impacted by sudden request spikes while serving incoming traffic in the most optimal manner. Having a well-defined, robust rate-limiting mechanism will be beneficial for both service providers and consumers.

In any API-based system, monitoring API usage and other related facts is an important task. It will help organizations to offer a better customer experience while exposing their services in the most optimal manner. This is common for GraphQL-based APIs as well. With the help of an API management solution, it will be a significant value addition to the GraphQL API.

Analytics and reporting

All the above QoS aspects are supported by WSO2’s API management solution. It provides a set of tools and documentation for API developers and application developers. Hence, it can be used to unlock and reap the full benefits of GraphQL APIs while offering a full set of QoS.

Conclusion

In order to survive and thrive in today’s technology space, it is vital to keep up with the latest innovations and technologies. These innovations will help an enterprise to serve modern consumer requirements while leveraging the effective problem-solving capabilities of those new technologies.

When it comes to the API management space, GraphQL is one such innovation. GraphQL has its own set of advantages. Because of these advantages, many innovative companies have adapted to this trend. To reap the maximum benefits, we can combine strong API management solutions with GraphQL. API management solutions will further enhance the experience and QoS for both developers and users.

Since WSO2 API Manager is a complete, enterprise-ready solution for managing APIs across the complete API lifecycle, organizations can use it to manage GraphQL APIs in any kind of complex production environment, while also adhering to API management best practices.

GraphQL and API Management - a Perfect Combination of Technologies