Skip to content
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

Add support for custom validators #268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JoaRiski
Copy link

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

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 graphql-python#267
@JoaRiski
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for custom validators in default GraphQL backend
1 participant