Skip to content

Commit 76799b8

Browse files
committed
add support for validation rules
1 parent c03e1a4 commit 76799b8

File tree

19 files changed

+560
-0
lines changed

19 files changed

+560
-0
lines changed

docs/aiohttp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ gql_view(request) # <-- the instance is callable and expects a `aiohttp.web.Req
5959
`Template.render_async` instead of `Template.render`. If environment is not set, fallbacks to simple regex-based renderer.
6060
* `batch`: Set the GraphQL view as batch (for using in [Apollo-Client](http://dev.apollodata.com/core/network.html#query-batching) or [ReactRelayNetworkLayer](https://github.com/nodkz/react-relay-network-layer))
6161
* `middleware`: A list of graphql [middlewares](http://docs.graphene-python.org/en/latest/execution/middleware/).
62+
* `validation_rules`: A list of graphql validation rules.
6263
* `max_age`: Sets the response header Access-Control-Max-Age for preflight requests.
6364
* `encode`: the encoder to use for responses (sensibly defaults to `graphql_server.json_encode`).
6465
* `format_error`: the error formatter to use for responses (sensibly defaults to `graphql_server.default_format_error`.

docs/flask.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ More info at [Graphene v3 release notes](https://github.com/graphql-python/graph
5858
* `graphiql_html_title`: The graphiql title to display. Defaults to **"GraphiQL"**.
5959
* `batch`: Set the GraphQL view as batch (for using in [Apollo-Client](http://dev.apollodata.com/core/network.html#query-batching) or [ReactRelayNetworkLayer](https://github.com/nodkz/react-relay-network-layer))
6060
* `middleware`: A list of graphql [middlewares](http://docs.graphene-python.org/en/latest/execution/middleware/).
61+
* `validation_rules`: A list of graphql validation rules.
6162
* `encode`: the encoder to use for responses (sensibly defaults to `graphql_server.json_encode`).
6263
* `format_error`: the error formatter to use for responses (sensibly defaults to `graphql_server.default_format_error`.
6364
* `subscriptions`: The GraphiQL socket endpoint for using subscriptions in graphql-ws.

docs/sanic.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ This will add `/graphql` endpoint to your app and enable the GraphiQL IDE.
5151
`Template.render_async` instead of `Template.render`. If environment is not set, fallbacks to simple regex-based renderer.
5252
* `batch`: Set the GraphQL view as batch (for using in [Apollo-Client](http://dev.apollodata.com/core/network.html#query-batching) or [ReactRelayNetworkLayer](https://github.com/nodkz/react-relay-network-layer))
5353
* `middleware`: A list of graphql [middlewares](http://docs.graphene-python.org/en/latest/execution/middleware/).
54+
* `validation_rules`: A list of graphql validation rules.
5455
* `max_age`: Sets the response header Access-Control-Max-Age for preflight requests.
5556
* `encode`: the encoder to use for responses (sensibly defaults to `graphql_server.json_encode`).
5657
* `format_error`: the error formatter to use for responses (sensibly defaults to `graphql_server.default_format_error`.

docs/webob.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ This will add `/graphql` endpoint to your app and enable the GraphiQL IDE.
4848
* `graphiql_html_title`: The graphiql title to display. Defaults to **"GraphiQL"**.
4949
* `batch`: Set the GraphQL view as batch (for using in [Apollo-Client](http://dev.apollodata.com/core/network.html#query-batching) or [ReactRelayNetworkLayer](https://github.com/nodkz/react-relay-network-layer))
5050
* `middleware`: A list of graphql [middlewares](http://docs.graphene-python.org/en/latest/execution/middleware/).
51+
* `validation_rules`: A list of graphql validation rules.
5152
* `encode`: the encoder to use for responses (sensibly defaults to `graphql_server.json_encode`).
5253
* `format_error`: the error formatter to use for responses (sensibly defaults to `graphql_server.default_format_error`.
5354
* `enable_async`: whether `async` mode will be enabled.

graphql_server/aiohttp/graphqlview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class GraphQLView:
3434
graphiql_template = None
3535
graphiql_html_title = None
3636
middleware = None
37+
validation_rules = None
3738
batch = False
3839
jinja_env = None
3940
max_age = 86400
@@ -75,6 +76,9 @@ def get_context(self, request):
7576
def get_middleware(self):
7677
return self.middleware
7778

79+
def get_validation_rules(self):
80+
return self.validation_rules
81+
7882
@staticmethod
7983
async def parse_body(request):
8084
content_type = request.content_type
@@ -149,6 +153,7 @@ async def __call__(self, request):
149153
root_value=self.get_root_value(),
150154
context_value=self.get_context(request),
151155
middleware=self.get_middleware(),
156+
validation_rules=self.get_validation_rules()
152157
)
153158

154159
exec_res = (

graphql_server/flask/graphqlview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class GraphQLView(View):
3535
graphiql_template = None
3636
graphiql_html_title = None
3737
middleware = None
38+
validation_rules = None
3839
batch = False
3940
subscriptions = None
4041
headers = None
@@ -73,6 +74,9 @@ def get_context(self):
7374
def get_middleware(self):
7475
return self.middleware
7576

77+
def get_validation_rules(self):
78+
return self.validation_rules
79+
7680
def dispatch_request(self):
7781
try:
7882
request_method = request.method.lower()
@@ -95,6 +99,7 @@ def dispatch_request(self):
9599
root_value=self.get_root_value(),
96100
context_value=self.get_context(),
97101
middleware=self.get_middleware(),
102+
validation_rules=self.get_validation_rules()
98103
)
99104
result, status_code = encode_execution_results(
100105
execution_results,

graphql_server/quart/graphqlview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class GraphQLView(View):
3737
graphiql_template = None
3838
graphiql_html_title = None
3939
middleware = None
40+
validation_rules = None
4041
batch = False
4142
enable_async = False
4243
subscriptions = None
@@ -76,6 +77,9 @@ def get_context(self):
7677
def get_middleware(self):
7778
return self.middleware
7879

80+
def get_validation_rules(self):
81+
return self.validation_rules
82+
7983
async def dispatch_request(self):
8084
try:
8185
request_method = request.method.lower()
@@ -98,6 +102,7 @@ async def dispatch_request(self):
98102
root_value=self.get_root_value(),
99103
context_value=self.get_context(),
100104
middleware=self.get_middleware(),
105+
validation_rules=self.get_validation_rules()
101106
)
102107
exec_res = (
103108
[

graphql_server/sanic/graphqlview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class GraphQLView(HTTPMethodView):
3636
graphiql_template = None
3737
graphiql_html_title = None
3838
middleware = None
39+
validation_rules = None
3940
batch = False
4041
jinja_env = None
4142
max_age = 86400
@@ -77,6 +78,9 @@ def get_context(self, request):
7778
def get_middleware(self):
7879
return self.middleware
7980

81+
def get_validation_rules(self):
82+
return self.validation_rules
83+
8084
async def dispatch_request(self, request, *args, **kwargs):
8185
try:
8286
request_method = request.method.lower()
@@ -103,6 +107,7 @@ async def dispatch_request(self, request, *args, **kwargs):
103107
root_value=self.get_root_value(),
104108
context_value=self.get_context(request),
105109
middleware=self.get_middleware(),
110+
validation_rules=self.get_validation_rules()
106111
)
107112
exec_res = (
108113
[

graphql_server/webob/graphqlview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class GraphQLView:
3535
graphiql_template = None
3636
graphiql_html_title = None
3737
middleware = None
38+
validation_rules = None
3839
batch = False
3940
enable_async = False
4041
subscriptions = None
@@ -73,6 +74,9 @@ def get_context(self, request):
7374
def get_middleware(self):
7475
return self.middleware
7576

77+
def get_validation_rules(self):
78+
return self.validation_rules
79+
7680
def dispatch_request(self, request):
7781
try:
7882
request_method = request.method.lower()
@@ -98,6 +102,7 @@ def dispatch_request(self, request):
98102
root_value=self.get_root_value(),
99103
context_value=self.get_context(request),
100104
middleware=self.get_middleware(),
105+
validation_rules=self.get_validation_rules()
101106
)
102107
result, status_code = encode_execution_results(
103108
execution_results,

0 commit comments

Comments
 (0)