Simplify GraphQL API Reusability at Scale with gqleX Open Source Library

Yaron Karni
Intuit Engineering
Published in
3 min readMay 6, 2024

The pace of GraphQL API query language adoption by application developers seeking a simpler way to produce, reuse and evolve existing API queries is on the rise. In fact, a Gartner report predicts that more than 50% of enterprises will use GraphQL in production by 2025, up from less than 10% in 2021.

The structure of the language allows developers to consolidate API calls into a single server call. This can dramatically improve performance for API queries involving large, complex, and interrelated data sources over traditional REST (representational state transfer) API methods involving simple data sources where resources are well defined. REST has multiple endpoints in the form of URLs to define resources, while GraphQL has a single URL endpoint.

However, for developers unfamiliar with the inner workings of existing GraphQL API code, it’s not so easy to reuse existing code, as noted by companies like Netflix and LinkedIn — and Intuit. Modifying a GraphQL document is a complicated process requiring developers to: 1) map out the entire API so the relationships among its nodes are clear, 2) identify the nodes relevant to the current use case, 3) manipulate the relevant nodes as required to support that use case, and 4) create a new API using the manipulated nodes.

That’s why our team has developed and contributed gqleX to the open source community, a Java-based code library for navigating, mapping and transforming existing GraphQL API queries into reusable code.

How gqleX works

Using the gqleX code library, a developer can easily map out every element in a GraphQL document in relation to the node and context in which it operates, enabling them to:

  • Identify and select relevant nodes using gqlXPath, a syntax similar to Xpath in XML or JSONPath in JSON. The library also provides an equivalent code called SyntaxPath, designed to support automated code selection.
  • Take advantage of a set of transformer capabilities to add children or sibling nodes, duplicate nodes, remove children nodes, update node names and/or update field aliases.

Upon completion of the transformation, they can produce a full-fledged new GraphQL API using the skeleton GraphQL file created by gqleX.

How gqleX can help

Throughout the development cycle, gqleX can be a useful tool.

For example, during base code development developers can enrich APIs with set dynamic fields for GraphQL (according to the required relational mapping fields) to query or dynamically perform any necessary data manipulation on the server side.

An integral feature of the library is to easily integrate changes in the graphql document: adding new fields, removing fields, updating fields, etc. It can also help speed up the creation of synthetic GraphQL data during API testing, which can be especially useful for fine-tuning integrations or enterprise-to-enterprise data connections. And, it can help companies standardize data queries across the enterprise as a means for setting and enforcing data policies within a flexible, streamlined development environment.

Join our gqleX community and contribute!

To learn more about gqleX, go to Intuit’s developer blog at GraphQL, gqlXPath, and Enhanced Transformer and access the source code on GitHub. We look forward to your feedback and contributions to our project.

--

--

Yaron Karni
Intuit Engineering

For 25 years, I've focused on software engineering. I have been a chief architect at Amobee, and Imvision. Led innovation labs at Ribbon and similar org,