-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: Semantics and complexity of GraphQL #6
Comments
I am not 100% sure if I understood the paper correctly, but I think this is roughly what this library does. The graphql-js library brings the query into the non-redundant ground-typed normal form, after that, the normalized query is passed to the validation rule which evaluates the cost of the query with a similar algorithm. What parts of the implementation did you want to change / add? |
@ivome - I was just trying to understand rather than change things. There are a bunch of different libraries that try to limit complexity of GraphQL queries, I'm trying to wrap my head around which approach is closest to being accurate. |
The full text of final version of this paper can be found here: https://dl.acm.org/citation.cfm?id=3186014 All I know is that the algorithm described in this paper compute the size of a GraphQL query result (response) without generating this result. The good thing: this algorithm is polynomial in the size of the data and the query/request. Maybe @hartig and @jorgeperezrojas can explain more. 😉 |
See also apollographql/apollo-server#1310. |
@ivome @brysgo I have added a few remarks regarding our paper/algorithm in the following comment apollographql/apollo-server#1310 (comment) |
@hartig - That is great! The formal outline of the algorithm is too foreign to me but I can't wait to take a look at the implementation your student put together. I think that this is an attack vector that our servers should protect against by default. |
I just released a new version with some major changes. Most notably the concept of configurable estimators: We can now create custom estimators that calculate the complexity on a per field basis. We can combine multiple estimators, defined default estimators that are applied to the whole schema etc. @hartig Maybe the new architecture is of help to implement the scientific paper? But I think the current implementation is already pretty close to the described algorithm if I understood the paper correctly. |
@ivome Unfortunately, I do not have the time to take a look at your implementation. However, if you are using estimators, it cannot be an implementation of the algorithm introduced in our paper because our algorithm returns the exact size of the query results. By the way, we have an implementation of the algorithm now. Take a look at: https://github.com/LiUGraphQL/graphql-result-size Moreover, in the meantime I have also written an informal summary of the paper, including an example that demonstrates how the algorithm works: |
@hartig Thank you for the links and the information. I have written a detailed comment here as this thread already provides a little bit more context: |
I found this paper pretty interesting and wanted to see what people thought. Is it worth trying to implement?
https://blog.acolyer.org/2018/05/21/semantics-and-complexity-of-graphql/?blogsub=confirming#subscribe-blog
The text was updated successfully, but these errors were encountered: