BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News restQL, a Microservices Query Language, Released on GitHub

restQL, a Microservices Query Language, Released on GitHub

Leia em Português

This item in japanese

restQL, a query language for microservices, is now available as an open-source project under an MIT license. The restQL language is intended to simplify common scenarios for client-side access to RESTful microservices, including multiple parallel calls and chained calls. Developed by B2W, the largest e-commerce operation in Latin America, restQL was created to avoid some limitations of the more well-known data querying and management frameworks Falcor and GraphQL.

While Falcor is only available to JavaScript clients, restQL is available to any client that supports REST calls over HTTP. This allows for its use in mobile apps written in Swift and Java. Although GraphQL is now a mature language for querying data, it doesn't provide some of the simple or well-established features available for RESTful services, such as HTTP response codes or native browser caching.

Similar to other querying languages, restQL statements describe the resources to retrieve, filtered by parameters. For example:

	from hero
	    with
        name = "Restman"

By default, queries are executed in parallel, without any special syntax. More complex, but common scenarios, such as chained or multiplexed calls (example below) are also straightforward.

	from hero
	    with
	        name = "Restman"
	
	from sidekick
	    with
	        hero = hero.id

Parsing and responding to restQL queries is handled by the restQL server. The server, implemented in Clojure, acts as a bridge between clients that submit restQL queries and backend APIs. Only configuration information is stored on the server, to pair resource names with the corresponding invocation endpoints. Because the restQL server exposes a standard REST endpoint, a specialized client is not required.

In a blog post announcing restQL, Ricardo Mayerhofer, IT Manager at B2W Digital, and one of the authors of restQL, said the project came about during the company's microservices migration. The development teams quickly benefitted from a move to microservices, with smaller applications to support, and corresponding easier maintenance. However, front-end code became more complex, having to orchestrate calls to multiple microservices, instead of a single, large call to the old monolith. Mayerhofer summarized their experience, saying, "A microservice-based architecture isn't a silver bullet. Despite its immediate benefits to the service teams, it poses by its very nature a challenge in terms of complexity and performance to the consumers." After considering Falcor and GraphQL, restQL was developed, and proved instrumental in simplifying client access to the multitude of backend services.

More information about restQL can be found at the project home page at http://restql.b2w.io/. The source code is available on GitHub.

Rate this Article

Adoption
Style

BT