Skip to content

Commit c738d3d

Browse files
committed
Added support for graphql 0.5.0
1 parent 76ea7d7 commit c738d3d

23 files changed

+87
-51
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ install:
2525
if [ "$TEST_TYPE" = build ]; then
2626
pip install --download-cache $HOME/.cache/pip/ pytest pytest-cov coveralls six pytest-django django-filter sqlalchemy_utils
2727
pip install --download-cache $HOME/.cache/pip psycopg2 > /dev/null 2>&1
28+
pip install https://github.com/graphql-python/graphql-core/archive/master.zip
29+
pip install https://github.com/graphql-python/graphql-relay-py/archive/master.zip
2830
pip install --download-cache $HOME/.cache/pip/ -e .[django]
2931
pip install --download-cache $HOME/.cache/pip/ -e .[sqlalchemy]
3032
pip install django==$DJANGO_VERSION

graphene/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
)
3434

3535
from graphene.utils import (
36-
resolve_only_args
36+
resolve_only_args,
37+
with_context
3738
)
3839

3940
__all__ = [

graphene/contrib/django/debug/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def wrap_schema(self, schema_type):
7272

7373
@contextmanager
7474
def context_execution(self, executor):
75-
executor['root'] = WrappedRoot(root=executor['root'])
75+
executor['root_value'] = WrappedRoot(root=executor.get('root_value'))
7676
executor['schema'] = self.wrap_schema(executor['schema'])
77-
self.enable_instrumentation(executor['root'])
77+
self.enable_instrumentation(executor['root_value'])
7878
yield executor
7979
self.disable_instrumentation()

graphene/contrib/django/debug/tests/test_query.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def resolve_all_reporters(self, *args, **kwargs):
149149
schema = graphene.Schema(query=Query, plugins=[DjangoDebugPlugin()])
150150
result = schema.execute(query)
151151
assert not result.errors
152+
print result.data['__debug']['sql']
152153
assert result.data['allReporters'] == expected['allReporters']
153154
assert 'COUNT' in result.data['__debug']['sql'][0]['rawSql']
154155
query = str(Reporter.objects.all()[:1].query)

graphene/contrib/django/filter/filterset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class GlobalIDFilter(Filter):
1414
field_class = GlobalIDFormField
1515

1616
def filter(self, qs, value):
17-
gid = from_global_id(value)
18-
return super(GlobalIDFilter, self).filter(qs, gid.id)
17+
_type, _id = from_global_id(value)
18+
return super(GlobalIDFilter, self).filter(qs, _id)
1919

2020

2121
class GlobalIDMultipleChoiceFilter(MultipleChoiceFilter):
2222
field_class = GlobalIDMultipleChoiceField
2323

2424
def filter(self, qs, value):
25-
gids = [from_global_id(v).id for v in value]
25+
gids = [from_global_id(v)[1] for v in value]
2626
return super(GlobalIDMultipleChoiceFilter, self).filter(qs, gids)
2727

2828

graphene/contrib/django/forms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def clean(self, value):
1616
return None
1717

1818
try:
19-
gid = from_global_id(value)
19+
_type, _id = from_global_id(value)
2020
except (TypeError, ValueError, UnicodeDecodeError, binascii.Error):
2121
raise ValidationError(self.error_messages['invalid'])
2222

2323
try:
24-
IntegerField().clean(gid.id)
25-
CharField().clean(gid.type)
24+
IntegerField().clean(_id)
25+
CharField().clean(_type)
2626
except ValidationError:
2727
raise ValidationError(self.error_messages['invalid'])
2828

graphene/contrib/django/views.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,3 @@ def __init__(self, schema, **kwargs):
1111
executor=schema.executor,
1212
**kwargs
1313
)
14-
15-
def execute(self, *args, **kwargs):
16-
return self.graphene_schema.execute(*args, **kwargs)

graphene/core/classtypes/tests/test_uniontype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ class Meta:
2525
assert isinstance(object_type, GraphQLUnionType)
2626
assert Thing._meta.type_name == 'Thing'
2727
assert object_type.description == 'Thing union description'
28-
assert object_type.get_possible_types() == [schema.T(Human), schema.T(Pet)]
28+
assert object_type.get_types() == [schema.T(Human), schema.T(Pet)]

graphene/core/schema.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import inspect
2-
from collections import OrderedDict
32

4-
from graphql.execution.executors.sync import SyncExecutor
3+
from graphql import graphql
54
from graphql.type import GraphQLSchema as _GraphQLSchema
65
from graphql.utils.introspection_query import introspection_query
76
from graphql.utils.schema_printer import print_schema
@@ -116,10 +115,19 @@ def get_type(self, type_name):
116115
def types(self):
117116
return self._types_names
118117

119-
def execute(self, request='', root=None, args=None, **kwargs):
120-
kwargs = dict(kwargs, request=request, root=root, args=args, schema=self.schema)
118+
def execute(self, request_string='', root_value=None, variable_values=None,
119+
context_value=None, operation_name=None, executor=None):
120+
kwargs = dict(
121+
schema=self.schema,
122+
request_string=request_string,
123+
root_value=root_value,
124+
context_value=context_value,
125+
variable_values=variable_values,
126+
operation_name=operation_name,
127+
executor=executor or self._executor
128+
)
121129
with self.plugins.context_execution(**kwargs) as execute_kwargs:
122-
return self.executor.execute(**execute_kwargs)
130+
return graphql(**execute_kwargs)
123131

124132
def introspect(self):
125-
return self.execute(introspection_query).data
133+
return graphql(self.schema, introspection_query).data

graphene/core/tests/test_mutations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ def test_execute_mutations():
5858
'result': '5',
5959
}
6060
}
61-
result = schema.execute(query, root=object())
61+
result = schema.execute(query, root_value=object())
6262
assert not result.errors
6363
assert result.data == expected

0 commit comments

Comments
 (0)