juniper
juniper copied to clipboard
Add a way to abort to complex queries
In grahpql it is possible to produce quite complicated queries that could be used to exhaust resources. The simplest example of such an query would be a query that recursively loads the friends of the friends (and so on) of some person. Juniper should include a way to measure the complexity of a query and then be able to abort the query at programmer defined threshold. This should be done without evaluating parts of the query (i.e try to load the thing and abort after a fixed time). See this morning paper and the linked underlying orginal paper for a detailed description of the problem and proposed algorithm to calculate the complexity of a query without evaluating the query.
https://www.npmjs.com/package/graphql-cost-analysis
there's js libs for this which could be used for inspiration
Another good source of inspiration for the API imo is absinthe (the elixir graphql library): https://hexdocs.pm/absinthe/complexity-analysis.html
Thanks for all the references.
I'll look into implementing this. (Probably only after switching to graphql-parser).