Create graphql query cost calculator (GSoC task)

From Software Heritage Wiki
Jump to navigation Jump to search

Introduction

Implement the first version of a GraphQL query cost calculator as a middleware.

Task description

Since GraphQL exposes a graph, queries could get really complex and can add a lot of load to the storage systems. Eg: A query like this will execute at least 4 different storage queries in a single request.

Though it is possible to restrict queries by size/length, a basic query cost calculator is a necessity. The very first version can be implemented as a GraphQL middleware. This will involve finding the relative complexity of a query in the backend and some basic arithmetic to calculate the total query cost. The resulting number can be used to accept or reject a query. The same number can later be used for user level throttling and rate limiting as well.

Desirable skills

  • Python
  • Basic knowledge of a middleware.
  • SQL

Potential mentors