ABSTRACT
GraphQL is a recently proposed, and increasingly adopted, conceptual framework for providing a new type of data access interface on the Web. The framework includes a new graph query language whose semantics has been specified informally only. This has prevented the formal study of the main properties of the language. We embark on the formalization and study of GraphQL. To this end, we first formalize the semantics of GraphQL queries based on a labeled-graph data model. Thereafter, we analyze the language and show that it admits really efficient evaluation methods. In particular, we prove that the complexity of the GraphQL evaluation problem is NL-complete. Moreover, we show that the enumeration problem can be solved with constant delay. This implies that a server can answer a GraphQL query and send the response byte-by-byte while spending just a constant amount of time between every byte sent. Despite these positive results, we prove that the size of a GraphQL response might be prohibitively large for an internet scenario. We present experiments showing that current practical implementations suffer from this issue. We provide a solution to cope with this problem by showing that the total size of a GraphQL response can be computed in polynomial time. Our results on polynomial-time size computation plus the constant-delay enumeration can help developers to provide more robust GraphQL interfaces on the Web.
- 4Catalyzer Corporation. 2017. GraphQL Validation Complexity. https://github.com/4Catalyzer/graphql-validation-complexity/. (2017).Google Scholar
- Guillaume Bagan, Arnaud Durand, and Etienne Grandjean. 2007. On Acyclic Conjunctive Queries and Constant Delay Enumeration Computer Science Logic, 21st International Workshop, CSL 2007, 16th Annual Conference of the EACSL, Lausanne, Switzerland, September 11--15, 2007, Proceedings. 208--222. Google ScholarDigital Library
- Nadia Creignou, Markus Kröll, Reinhard Pichler, Sebastian Skritek, and Heribert Vollmer. 2017. On the Complexity of Hard Enumeration Problems. In Language and Automata Theory and Applications - 11th International Conference, LATA 2017, Umeå, Sweden, March 6--9, 2017, Proceedings. 183--195.Google Scholar
- Arnaud Durand, Nicole Schweikardt, and Luc Segoufin. 2014. Enumerating answers to first-order queries over databases of low degree Proceedings of the 33rd ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS'14, Snowbird, UT, USA, June 22--27, 2014. 121--131. Google ScholarDigital Library
- Facebook, Inc.. 2016. GraphQL. Working Draft, Oct. 2016. Online at: http://facebook.github.io/graphql, retrieved on Dec. 12, 2016. (Oct.. 2016).Google Scholar
- Georg Gottlob, Nicola Leone, and Francesco Scarcello. 2001. The complexity of acyclic conjunctive queries. J. ACM Vol. 48, 3 (2001), 431--498. Google ScholarDigital Library
- Olaf Hartig and Jorge Pérez. 2017. An Initial Analysis of Facebook's GraphQL Language Proceedings of the 11th Alberto Mendelzon International Workshop on Foundations of Data Management (AMW).Google Scholar
- D. S. Johnson. 1990. A catalog of complexity classes. In Handbook of Theoretical Computer Science, J. van Leeuwen (Ed.). Vol. Vol. A. Elsevier, Chapter 2. Google ScholarDigital Library
- Wojciech Kazana and Luc Segoufin. 2013. Enumeration of first-order queries on classes of structures with bounded expansion Proceedings of the 32nd ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS 2013, New York, NY, USA - June 22 - 27, 2013. 297--308. Google ScholarDigital Library
- Markus Kröll, Reinhard Pichler, and Sebastian Skritek. 2016. On the Complexity of Enumerating the Answers to Well-designed Pattern Trees 19th International Conference on Database Theory, ICDT 2016, Bordeaux, France, March 15--18, 2016. 22:1--22:18.Google Scholar
- Ivo Meißner. 2017. GraphQL Query Complexity Analysis for graphql-js. https://github.com/ivome/graphql-query-complexity/. (2017).Google Scholar
- Reinhard Pichler and Sebastian Skritek. 2013. Tractable counting of the answers to conjunctive queries. J. Comput. Syst. Sci. Vol. 79, 6 (2013), 984--1001. Google ScholarDigital Library
- Leonard Richardson, Mike Amundsen, and Sam Ruby. 2013. RESTful Web APIs. O'Reilly Media, Inc. Google ScholarDigital Library
- Luc Segoufin. 2013. Enumerating with constant delay the answers to a query Joint 2013 EDBT/ICDT Conferences, ICDT '13 Proceedings, Genoa, Italy, March 18--22, 2013. 10--20. Google ScholarDigital Library
- Luc Segoufin and Alexandre Vigny. 2017. Constant Delay Enumeration for FO Queries over Databases with Local Bounded Expansion 20th International Conference on Database Theory, ICDT 2017, March 21--24, 2017, Venice, Italy. 20:1--20:16.Google Scholar
- Stem Disintermedia, Inc.. 2016. Join Monster. https://github.com/stems/join-monster. (2016).Google Scholar
- Stem Disintermedia, Inc.. 2017. GraphQL Depth Limit. https://github.com/stems/graphql-depth-limit/. (2017).Google Scholar
- Moshe Y. Vardi. 1982. The Complexity of Relational Query Languages (Extended Abstract) Proceedings of the 14th Annual ACM Symposium on Theory of Computing, May 5--7, 1982, San Francisco, California, USA. 137--146. Google ScholarDigital Library
- Mihalis Yannakakis. 1981. Algorithms for Acyclic Database Schemes. In Very Large Data Bases, 7th International Conference, September 9--11, 1981, Cannes, France, Proceedings. 82--94. Google ScholarDigital Library
Index Terms
- Semantics and Complexity of GraphQL
Recommendations
GraphQL: A Systematic Mapping Study
GraphQL is a query language and execution engine for web application programming interfaces (APIs) proposed as an alternative to improve data access problems and versioning of representational state transfer APIs. In this article, we thoroughly study the ...
A principled approach to GraphQL query cost analysis
ESEC/FSE 2020: Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software EngineeringThe landscape of web APIs is evolving to meet new client requirements and to facilitate how providers fulfill them. A recent web API model is GraphQL, which is both a query language and a runtime. Using GraphQL, client queries express the data they want ...
A mechanized formalization of GraphQL
CPP 2020: Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and ProofsGraphQL is a novel language for specifying and querying web APIs, allowing clients to flexibly and efficiently retrieve data of interest. The GraphQL language specification is unfortunately only available in prose, making it hard to develop robust ...
Comments