Skip to Main content Skip to Navigation
Conference papers

A Principled Approach to GraphQL Query Cost Analysis

Alan Cha 1 Erik Wittern 1 Guillaume Baudart 2, 3 James C. Davis 4 Louis Mandel 1 Jim A. Laredo 1
3 Parkas - Parallélisme de Kahn Synchrone
DI-ENS - Département d'informatique de l'École normale supérieure, CNRS - Centre National de la Recherche Scientifique, Inria de Paris
Abstract : The 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 to retrieve or mutate, and servers respond with exactly those data or changes. GraphQL's expressiveness is risky for service providers because clients can succinctly request stupendous amounts of data, and responding to overly complex queries can be costly or disrupt service availability. Recent empirical work has shown that many service providers are at risk. Using traditional API management methods is not sufficient, and practitioners lack principled means of estimating and measuring the cost of the GraphQL queries they receive. In this work, we present a linear-time GraphQL query analysis that can measure the cost of a query without executing it. Our approach can be applied in a separate API management layer and used with arbitrary GraphQL backends. In contrast to existing static approaches, our analysis supports common GraphQL conventions that affect query cost, and our analysis is provably correct based on our formal specification of GraphQL semantics. We demonstrate the potential of our approach using a novel GraphQL query-response corpus for two commercial GraphQL APIs. Our query analysis consistently obtains upper cost bounds, tight enough relative to the true response sizes to be actionable for service providers. In contrast, existing static GraphQL query analyses exhibit over-estimates and under-estimates because they fail to support GraphQL conventions.
Complete list of metadatas

https://hal.inria.fr/hal-03117800
Contributor : Guillaume Baudart <>
Submitted on : Wednesday, January 27, 2021 - 10:11:56 AM
Last modification on : Wednesday, January 27, 2021 - 10:35:36 AM

File

fse20.pdf
Files produced by the author(s)

Identifiers

Collections

Citation

Alan Cha, Erik Wittern, Guillaume Baudart, James C. Davis, Louis Mandel, et al.. A Principled Approach to GraphQL Query Cost Analysis. ESEC/FSE 2020 - 28th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering, Nov 2020, Sacramento / Virtual, United States. ⟨10.1145/3368089.3409670⟩. ⟨hal-03117800⟩

Share

Metrics

Record views

31

Files downloads

67