graphql-python / graphql-server

This is the core package for using GraphQL in a custom server easily
MIT License
120 stars 72 forks source link

allow validation rules to be passed during schema execution #82

Closed aryaniyaps closed 3 years ago

aryaniyaps commented 3 years ago

validation rules are the recommended way to implement things like depth limit validators and other sorts of protectors. When inspecting the source code, I found out that validation_rules aren't passed as an argument during schema execution. It would be nice if this could be fixed so that we could implement our own validation rules.

https://github.com/graphql-python/graphql-server/blob/c03e1a4177233b0a053948c96ce862314d52e7bf/graphql_server/flask/graphqlview.py#L87-L98

over here, the http query is run via the run_http_query function. This method also takes other execution options, as shown below.

https://github.com/graphql-python/graphql-server/blob/c03e1a4177233b0a053948c96ce862314d52e7bf/graphql_server/__init__.py#L58-L67

Inside the run_http_query method, this function is called.

https://github.com/graphql-python/graphql-server/blob/c03e1a4177233b0a053948c96ce862314d52e7bf/graphql_server/__init__.py#L122-L124

this function, get_response takes another execution option, validation_rules. This is not being passed anywhere, and always remains None.

https://github.com/graphql-python/graphql-server/blob/c03e1a4177233b0a053948c96ce862314d52e7bf/graphql_server/__init__.py#L234-L243

I will send a PR ASAP!