Generating GraphQL-Wrappers for REST(-like) APIs

GraphQL is a query language and thereupon-based paradigm for implementing web Application Programming Interfaces (APIs) for client-server interactions. Using GraphQL, clients define precise, nested data-requirements in typed queries, which are resolved by servers against (possibly multiple) backend systems, like databases, object storages, or other APIs. Clients receive only the data they care about, in a single request. However, providers of existing REST(-like) APIs need to implement additional GraphQL interfaces to enable these advantages. We here assess the feasibility of automatically generating GraphQL wrappers for existing REST(-like) APIs. A wrapper, upon receiving GraphQL queries, translates them to requests against the target API. We discuss the challenges for creating such wrappers, including dealing with data sanitation, authentication, or handling nested queries. We furthermore present a prototypical implementation of OASGraph. OASGraph takes as input an OpenAPI Specification (OAS) describing an existing REST(-like) web API and generates a GraphQL wrapper for it. We evaluate OASGraph by running it, as well as an existing open source alternative, against 959 publicly available OAS. This experiment shows that OASGraph outperforms the existing alternative and is able to create a GraphQL wrapper for \(89.5\%\) of the APIs – however, with limitations in many cases. A subsequent analysis of errors and warnings produced by OASGraph shows that missing or ambiguous information in the assessed OAS hinders creating complete wrappers. Finally, we present a use case of the IBM Watson Language Translator API that shows that small changes to an OAS allow OASGraph to generate more idiomatic and more expressive GraphQL wrappers.

[1]  Frank Maurer,et al.  SpyREST: Automated RESTful API Documentation Using an HTTP Proxy Server (N) , 2015, 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[2]  Fabio Casati,et al.  REST APIs: A Large-Scale Analysis of Compliance with Principles and Best Practices , 2016, ICWE.

[3]  Petri Selonen,et al.  Towards a Model-Driven Process for Designing ReSTful Web Services , 2009, 2009 IEEE International Conference on Web Services.

[4]  Kyriakos C. Chatzidimitriou,et al.  From requirements to source code: a Model-Driven Engineering approach for RESTful web services , 2017, Automated Software Engineering.

[5]  E. Michael Maximilien,et al.  A Domain-Specific Language for Web APIs and Services Mashups , 2007, ICSOC.

[6]  Martin Hirzel,et al.  Generating chat bots from web API specifications , 2017, Onward!.

[7]  Jordi Cabot,et al.  EMF-REST: generation of RESTful APIs from models , 2016, SAC.

[8]  Jun Li,et al.  How Does Web Service API Evolution Affect Clients? , 2013, 2013 IEEE 20th International Conference on Web Services.

[9]  Philippe Suter,et al.  Inferring Web API Descriptions from Usage Data , 2015, 2015 Third IEEE Workshop on Hot Topics in Web Systems and Technologies (HotWeb).

[10]  Carsten Bormann,et al.  JSONPath -- XPath for JSON , 2020 .

[11]  Andy Zaidman,et al.  Web API growing pains: Stories from client developers and their code , 2014, 2014 Software Evolution Week - IEEE Conference on Software Maintenance, Reengineering, and Reverse Engineering (CSMR-WCRE).

[12]  Markus Scheidgen,et al.  Metamodeling vs Metaprogramming: A Case Study on Developing Client Libraries for REST APIs , 2016, ECMFA.