graphql-core-legacy icon indicating copy to clipboard operation
graphql-core-legacy copied to clipboard

Add support for custom validators

Open JoaRiski opened this issue 5 years ago • 1 comments

Support extending the GraphQLCoreBackend class with custom validators by adding a function get_validation_rules that can be overridden in subclasses where needed.

This change in combination with setting the default graphql backend allows for easy additions to validation rules. An example use case would be if there's a need to perform query cost or depth analysis, one can create a validator that restricts execution of the query based on it's execution cost.

Of course this could also be used to remove validators if that is necessary for some use case.

Resolves #267

JoaRiski avatar Feb 25 '20 23:02 JoaRiski

Seems like Python 3.5 doesn't like mock's assert_called_once function, will have to check that. Let me know if there's something else wrong with this and I'll include those changes at the same time.

JoaRiski avatar Feb 25 '20 23:02 JoaRiski