GraphQL is Like Your Kids All Grown Up
Blog: The Tibco Blog
Like many kids, when my daughter was young, she was only able to focus on one simple task at a time until it was done. She wasn’t yet capable of organizing multiple tasks in her head, or breaking down bigger goals—such as getting the house clean—into a series of smaller tasks. So I’d have to create a detailed list for her of all the chores that she needed to get done. It would have been a lot easier if I could have just expressed the big picture goal to her one time and—Boom!—she would have gotten it done. But such is the life of a parent.
RESTful APIs, like young children, are singly focused
For developers, RESTful APIs are similar to young kids. RESTful APIs make Web Services simple because they can be invoked by an application using HTTP. Your application links to a specific web resource (an endpoint) that is identified within the URL and gets data back in return. So for example, a mobile app maintained by an airline could invoke a RESTful API that queried all flights departing one airport and arriving at another on a specific date, depending on the user’s input. The API would return all data for those flights, and the app would parse out only the data it needed for display to the end user.
However, like a child who can only focus on one simple task at a time, a RESTful API allows a user to only query or post data for the specific web resource to which it is coupled (e.g. ‘flights’). More complex queries involving multiple web resources – which could span across your enterprise – require that your application invoke multiple RESTful APIs, and process large volumes of data to get the dataset required.
Extending the example above, suppose our airline wanted to personalize their mobile app with dynamic pricing for their flights, where the prices of selected flights for the user were based on their status within the airline’s customer loyalty program. This use case would require several RESTful API requests across web resources maintained by different functional areas of the business.
So as you can see, much like with young kids, in order to achieve a broad goal (obtaining a specific data set queries across several web resources) with RESTful APIs, your application must break it down into multiple API requests. This can consume a fair amount of developer time, network bandwidth, and client-side compute resources—creating a negative experience for end-users such as your customers.
GraphQL can handle complex queries that would require multiple RESTful APIs
GraphQL, on the other hand, is an open-source query language and runtime for developing more flexible APIs. Like RESTful APIs, they are invoked over HTTP with a URL. But unlike RESTful APIs, they are not coupled to a single web resource, and the data they return can be customized to the needs of the user.
Thus, complex queries that would ordinarily require multiple RESTful APIs can instead be accomplished within a single GraphQL API. This makes it much easier for your partners and customers to consume your digital services and provides them with a more responsive experience.
GraphQL provides more than just technical benefits. Because of its flexibility, GraphQL allows you to expose all of your digital services within a single view—services that are implemented across diverse information systems and departments within your enterprise. As seen in our example, it allows the airline’s customer loyalty program and flight booking organizations to appear to work together seamlessly for the end-user. GraphQL thus allows you to easily break down information silos across your business and create rich, seamless digital experiences.
An agile API program has a combination of both RESTful and GraphQL APIs
GraphQL APIs won’t necessarily replace your RESTful APIs, as both have a place in your overall API program. A highly agile API program that is easy to consume and provides rich client experiences utilizes a variety of API technologies to best meet the needs of the API consumer.
TIBCO Cloud Integration is the first Integration Platform-as-a-Service (iPaaS) to provide native support for GraphQL. Available within TIBCO Cloud, developers can use TIBCO Cloud Integration to build applications that are based on open source Project Flogo®. Flogo® apps are event-driven, consisting of one or more triggers that receive events from external sources such as a GraphQL request, and actions that contain logic to process those events. Flogo® apps, therefore, can act as a GraphQL server. GraphQL schemas can be imported into a Flogo® app, and GraphQL triggers can be automatically generated from them.
With GraphQL support embedded in TIBCO Cloud Integration, you accelerate the development of GraphQL APIs: you eliminate the need to install and configure your own GraphQL server, you can more quickly implement GraphQL APIs using a visual flow designer, and you can easily connect to a wide number of systems and data sources using our pre-built connectors.
GraphQL is like your kids all grown up. It can handle multiple tasks and you don’t need to break them down into single ones. You can get started with GraphQL today by registering for a trial edition of TIBCO Cloud Integration.