Permalink
Browse files

Removed executor and middleware from the Schema.

  • Loading branch information...
1 parent 227d942 commit 0148401c0694893ef57d6b52a40adae272e6ebd5 @syrusakbary syrusakbary committed Sep 20, 2016
Showing with 15 additions and 28 deletions.
  1. +5 −1 UPGRADE-v1.0.md
  2. +3 −3 examples/starwars/tests/test_query.py
  3. +5 −22 graphene/types/schema.py
  4. +2 −2 graphene/types/tests/test_query.py
View
@@ -75,7 +75,11 @@ We have done our best to provide backwards compatibility with deprecated APIs.
Schemas in graphene `1.0` are `Immutable`, that means that once you create a `graphene.Schema` any
change in their attributes will not have any effect.
-Also the `name` argument is removed from the Schema.
+The `name` argument is removed from the Schema.
+
+The arguments `executor` and `middlewares` are also removed from the `Schema` definition.
+You can still use them, but by calling explicitly in the `execute` method in `graphql`.
+
```python
# Old way
@@ -163,7 +163,7 @@ def test_fetch_some_id_query():
'name': 'Luke Skywalker',
}
}
- result = schema.execute(query, None, params)
+ result = schema.execute(query, None, variable_values=params)
assert not result.errors
assert result.data == expected
@@ -184,7 +184,7 @@ def test_fetch_some_id_query2():
'name': 'Han Solo',
}
}
- result = schema.execute(query, None, params)
+ result = schema.execute(query, None, variable_values=params)
assert not result.errors
assert result.data == expected
@@ -203,7 +203,7 @@ def test_invalid_id_query():
expected = {
'human': None
}
- result = schema.execute(query, None, params)
+ result = schema.execute(query, None, variable_values=params)
assert not result.errors
assert result.data == expected
@@ -1,5 +1,5 @@
-from graphql import GraphQLSchema, MiddlewareManager, graphql, is_type
+from graphql import GraphQLSchema, graphql, is_type
from graphql.type.directives import (GraphQLDirective, GraphQLIncludeDirective,
GraphQLSkipDirective)
from graphql.type.introspection import IntrospectionSchema
@@ -14,18 +14,15 @@ class Schema(GraphQLSchema):
Schema Definition
A Schema is created by supplying the root types of each type of operation,
- query and mutation (optional). A schema definition is then supplied to the
- validator and executor.
+ query and mutation (optional).
'''
def __init__(self, query=None, mutation=None, subscription=None,
- directives=None, types=None, executor=None, middlewares=None,
- auto_camelcase=True):
+ directives=None, types=None, auto_camelcase=True):
self._query = query
self._mutation = mutation
self._subscription = subscription
self.types = types
- self._executor = executor
self.auto_camelcase = auto_camelcase
if directives is None:
directives = [
@@ -37,10 +34,6 @@ def __init__(self, query=None, mutation=None, subscription=None,
'Schema directives must be List[GraphQLDirective] if provided but got: {}.'.format(
directives
)
- if middlewares:
- self.middlewares = MiddlewareManager(*middlewares)
- else:
- self.middlewares = None
self._directives = directives
self.build_typemap()
@@ -65,18 +58,8 @@ def get_graphql_type(self, _type):
return graphql_type
raise Exception("{} is not a valid GraphQL type.".format(_type))
- def execute(self, request_string='', root_value=None, variable_values=None,
- context_value=None, operation_name=None, executor=None):
- return graphql(
- schema=self,
- request_string=request_string,
- root_value=root_value,
- context_value=context_value,
- variable_values=variable_values,
- operation_name=operation_name,
- executor=executor or self._executor,
- middlewares=self.middlewares
- )
+ def execute(self, *args, **kwargs):
+ return graphql(self, *args, **kwargs)
def register(self, object_type):
self.types.append(object_type)
@@ -102,9 +102,9 @@ def reversed_middleware(next, *args, **kwargs):
p = next(*args, **kwargs)
return p.then(lambda x: x[::-1])
- hello_schema = Schema(Query, middlewares=[reversed_middleware])
+ hello_schema = Schema(Query)
- executed = hello_schema.execute('{ hello, other }')
+ executed = hello_schema.execute('{ hello, other }', middleware=[reversed_middleware])
assert not executed.errors
assert executed.data == {'hello': 'dlroW', 'other': 'rehto'}

0 comments on commit 0148401

Please sign in to comment.