Zero-Code GraphQL API Creation with the Denodo Platform
Reading Time: 4 minutes

The Denodo Platform enables seamless access to data views via GraphQL. No coding is required; the GraphQL API is generated by Denodo Platform metadata on the fly. You simply declare the data you want in a POST request to the Denodo Platform; that’s it!

In this post, we’ll illustrate how the Denodo GraphQL interface works. This is one example of how the Denodo Platform facilitates data services creation and data delivery. Other examples are the OData Service and the RESTful Web Service.

GraphQL: A Declarative API

GraphQL is a query language created by Facebook. In GraphQL:

  • Queries declare the data you want, so you receive only the data you want, and nothing more.
  • Relationships among objects are represented in a hierarchical way, providing an intuitive way for users to efficiently retrieve linked data in only one request.
  • Responses are predictable since they match the format of the queries.

For example, say you want to fetch just a few columns of a view called human. The GraphQL query and response might look like this:

GraphQL’s schema acts as a public API, modelling the kind of data exposed to the clients: objects, attributes of the objects, and relationships between them.

The GraphQL schema for the view called human of the previous example might look like this:

In brief, GraphQL:

  • Gives clients the power to ask for exactly what they need in an easy way and get it in a predictable format
  • Retrieves many resources from the server in a single request, reducing the number of server calls
  • Provides a strong-typed system, enabling query validation before execution

GraphQL Powered by the Denodo Platform

With the Denodo Platform running underneath, you can use the Denodo GraphQL interface in your web applications, mobile apps, or in your integrations with third-party tools, all while maintaining security, decouple your data consumers from your data sources, and optimizing your use cases.

With the Denodo GraphQL interface:

  • No coding is required for setting it up.

The GraphQL API is generated on the fly from the Denodo Platform metadata, providing a GraphQL endpoint for each Denodo database, with a query type per view.

  • No “N+1 problem.”

This is a common issue in GraphQL servers, since querying for linked objects in a one-to-many relationship would result in N+1 data source accesses when traversing the relationships among model objects.

But the Denodo GraphQL interface fetches the complete hierarchy of objects with only one query, hitting the data source only once. And the Denodo GraphQL interface works this way every time, for every single request, without users having to write a single line of code.

  • Users can leverage query optimization and caching capabilities.

The Denodo Platform can significantly improve the performance of your use cases by applying real-time query optimization and advanced caching techniques. Once again, no extra code is involved, just some tuning of the Denodo configuration settings to ensure that the optimizations are applied.

  • Security is enforced.

The Denodo Platform establishes a single point from which to control all data access, ensuring fine-grained user and role-based permissions for each and every element requested by a GraphQL query.

In addition, the Denodo GraphQL interface supports OAuth2 and Kerberos authentication methods without users needing to write a single line of code.

Let’s dig a little deeper into the previous example. Suppose we had a web service that lists, in JSON format, all the characters in the Star Wars saga. Also, let’s say we could get details about the most viewed films of this decade from another web service, this time in XML format.

This scenario could be modelled in the Denodo Platform by creating two base views, one for each web service, and adding an association between them, as illustrated below using Denodo Design Studio:

If we use the Denodo GraphQL API over this model, we would achieve great performance with the GraphQL queries that traverse the relationship between both web services.

See below, where we illustrate the execution of a query using the GraphQL API of the Denodo Platform:

The execution plan for this query through the Denodo Platform involves only one access to the most viewed films web service and one other access to the Star Wars characters web service. Other GraphQL servers would have to access the film web service multiple times, one for every Star Wars character.

Powerful, Efficient Queries

With GraphQL and the Denodo Platform, developers have a powerful new tool at their disposal. They can simply describe the data and services they need, and the Denodo Platform will efficiently deliver the data to the client’s device.

Denodo Labs