Generating GraphQL-Wrappers for REST(-like) APIs

  • Erik WitternEmail author
  • Alan Cha
  • Jim A. Laredo
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10845)


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. 1.
    Ed-douibi, H., Izquierdo, J.L.C., Gómez, A., Tisi, M., Cabot, J.: EMF-REST: generation of RESTful APIs from models. In: Proceedings of the 31st Annual ACM Symposium on Applied Computing, pp. 1446–1453. ACM (2016)Google Scholar
  2. 2.
    Espinha, T., Zaidman, A., Gross, H.G.: Web API growing pains: stories from client developers and their code. In: 2014 Software Evolution Week - IEEE Conference on Software Maintenance, Reengineering, and Reverse Engineering, CSMR-WCRE, pp. 84–93. IEEE, February 2014Google Scholar
  3. 3.
    Facebook Inc.: GraphQL (specification, working draft October 2016). Accessed 02 Nov 2017
  4. 4.
    Fielding, R.T., Taylor, R.N.: Architectural styles and the design of network-based software architectures. University of California, Irvine Doctoral dissertation (2000)Google Scholar
  5. 5.
    Gössner, S.: JSONPath - XPath for JSON. Accessed 12 Dec 2017
  6. 6.
    Internet Engineering Task Force: JSON Schema: A Media Type for Describing JSON Documents. Accessed 01 Dec 2017
  7. 7.
    Laitkorpi, M., Selonen, P., Systa, T.: Towards a model-driven process for designing ReSTful web services. In: 2009 IEEE International Conference on Web Services, ICWS, pp. 173–180. IEEE, July 2009Google Scholar
  8. 8.
    Li, J., Xiong, Y., Liu, X., Zhang, L.: How does web service API evolution affect clients? In: 2013 IEEE 20th International Conference on Web Services, pp. 300–307. IEEE, June 2013Google Scholar
  9. 9.
    Maximilien, E.M., Wilkinson, H., Desai, N., Tai, S.: A domain-specific language for web APIs and services mashups. In: Krämer, B.J., Lin, K.-J., Narasimhan, P. (eds.) ICSOC 2007. LNCS, vol. 4749, pp. 13–26. Springer, Heidelberg (2007). Scholar
  10. 10.
    OpenAPI Initiative: OpenAPI Specification (Version 3.0.0). Accessed 01 Dec 2017
  11. 11.
    Rodríguez, C., Baez, M., Daniel, F., Casati, F., Trabucco, J.C., Canali, L., Percannella, G.: REST APIs: a large-scale analysis of compliance with principles and best practices. In: Bozzon, A., Cudre-Maroux, P., Pautasso, C. (eds.) ICWE 2016. LNCS, vol. 9671, pp. 21–39. Springer, Cham (2016). Scholar
  12. 12.
    Scheidgen, M., Efftinge, S., Marticke, F.: Metamodeling vs Metaprogramming: a case study on developing client libraries for REST APIs. In: Wąsowski, A., Lönn, H. (eds.) ECMFA 2016. LNCS, vol. 9764, pp. 205–216. Springer, Cham (2016). Scholar
  13. 13.
    Sohan, S.M., Anslow, C., Maurer, F.: SpyREST: automated RESTful API documentation using an HTTP proxy server. In: Proceedings of the 30th IEEE/ACM International Conference on Automated Software Engineering, ASE, pp. 271–276. IEEE (2015)Google Scholar
  14. 14.
    Suter, P., Wittern, E.: Inferring web API descriptions from usage data. In: Proceedings of the Third IEEE Workshop on Hot Topics in Web Systems and Technologies, HotWeb, pp. 7–12. IEEE (2015)Google Scholar
  15. 15.
    Vaziri, M., Mandel, L., Shinnar, A., Siméon, J., Hirzel, M.: Generating chat bots from web API specifications. In: Proceedings of the 2017 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, Onward!, pp. 44–57. ACM (2017)Google Scholar
  16. 16.
    Zolotas, C., Diamantopoulos, T., Chatzidimitriou, K.C., Symeonidis, A.L.: From requirements to source code: a model-driven engineering approach for RESTful web services. Autom. Softw. Eng. 24(4), 791–838 (2017)CrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG, part of Springer Nature 2018

Authors and Affiliations

  1. 1.IBM T. J Watson Research CenterYorktown HeightsUSA
  2. 2.Columbia UniversityNew YorkUSA

Personalised recommendations