GraphQL图式的实证研究
An Empirical Study of GraphQL Schemas
摘要:
GraphQL是一种用于API的查询语言和执行查询的运行时。使用GraphQL查询,客户端可以精确定义他们希望在服务器上检索或更改的数据,从而减少往返次数并减少响应大小。尽管人们对GraphQL的兴趣正在上升,随着主要组织的采用越来越多,但人们对GraphQL接口在实践中的样子知之甚少。这种知识的缺乏使得提供者很难理解哪些实践促进了惯用的、易于使用的API,以及要避免哪些陷阱。为了解决这一差距,我们通过分析它们的模式来研究GraphQL接口的设计-它们暴露的数据类型的描述以及对底层数据的可能操作。我们的研究基于两个新的GraphQL模式语料库,一个是16个商业GraphQL模式,另一个是从GitHub项目中挖掘的8,399个GraphQL模式。我们将这两个语料库提供给其他研究人员。使用这些语料库,我们描述了模式的大小及其对GraphQL功能的使用,并评估了规定和有机命名约定的使用。我们还报告说,大多数API都容易通过复杂的查询拒绝服务,造成真正的安全风险,以前只在理论上讨论。我们还评估了GraphQL API试图解决这些问题的方法。
英文摘要:
GraphQL is a query language for APIs and a runtime to execute queries. Using GraphQL queries, clients define precisely what data they wish to retrieve or mutate on a server, leading to fewer round trips and reduced response sizes. Although interest in GraphQL is on the rise, with increasing adoption at major organizations, little is known about what GraphQL interfaces look like in practice. This lack of knowledge makes it hard for providers to understand what practices promote idiomatic, easy-to-use APIs, and what pitfalls to avoid. To address this gap, we study the design of GraphQL interfaces in practice by analyzing their schemas - the descriptions of their exposed data types and the possible operations on the underlying data. We base our study on two novel corpuses of GraphQL schemas, one of 16 commercial GraphQL schemas and the other of 8,399 GraphQL schemas mined from GitHub projects. We make both corpuses available to other researchers. Using these corpuses, we characterize the size of schemas and their use of GraphQL features and assess the use of both prescribed and organic naming conventions. We also report that a majority of APIs are susceptible to denial of service through complex queries, posing real security risks previously discussed only in theory. We also assess ways in which GraphQL APIs attempt to address these concerns.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。