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.
|
execution_results, all_params = run_http_query( |
|
self.schema, |
|
request_method, |
|
data, |
|
query_data=request.args, |
|
batch_enabled=self.batch, |
|
catch=catch, |
|
# Execute options |
|
root_value=self.get_root_value(), |
|
context_value=self.get_context(), |
|
middleware=self.get_middleware(), |
|
) |
over here, the http query is run via the run_http_query function.
This method also takes other execution options, as shown below.
|
def run_http_query( |
|
schema: GraphQLSchema, |
|
request_method: str, |
|
data: Union[Dict, List[Dict]], |
|
query_data: Optional[Dict] = None, |
|
batch_enabled: bool = False, |
|
catch: bool = False, |
|
run_sync: bool = True, |
|
**execute_options, |
|
) -> GraphQLResponse: |
Inside the run_http_query method, this function is called.
|
get_response( |
|
schema, params, catch_exc, allow_only_query, run_sync, **execute_options |
|
) |
this function, get_response takes another execution option, validation_rules.
This is not being passed anywhere, and always remains None.
|
def get_response( |
|
schema: GraphQLSchema, |
|
params: GraphQLParams, |
|
catch_exc: Type[BaseException], |
|
allow_only_query: bool = False, |
|
run_sync: bool = True, |
|
validation_rules: Optional[Collection[Type[ASTValidationRule]]] = None, |
|
max_errors: Optional[int] = None, |
|
**kwargs, |
|
) -> Optional[AwaitableOrValue[ExecutionResult]]: |
I will send a PR ASAP!
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_rulesaren'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.graphql-server/graphql_server/flask/graphqlview.py
Lines 87 to 98 in c03e1a4
over here, the http query is run via the
run_http_queryfunction.This method also takes other execution options, as shown below.
graphql-server/graphql_server/__init__.py
Lines 58 to 67 in c03e1a4
Inside the
run_http_querymethod, this function is called.graphql-server/graphql_server/__init__.py
Lines 122 to 124 in c03e1a4
this function,
get_responsetakes another execution option,validation_rules.This is not being passed anywhere, and always remains None.
graphql-server/graphql_server/__init__.py
Lines 234 to 243 in c03e1a4
I will send a PR ASAP!