mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-29 21:13:58 +03:00
Improved Python3 integration
This commit is contained in:
parent
948da46fcd
commit
b58269ce72
|
@ -38,7 +38,7 @@ class GraphQLView(View):
|
|||
try:
|
||||
result = self.schema.execute(query, root=object())
|
||||
data = self.format_result(result)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if settings.DEBUG:
|
||||
raise e
|
||||
return self.response_errors(e)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import inspect
|
||||
import six
|
||||
from graphql.core.type import (
|
||||
GraphQLField,
|
||||
GraphQLList,
|
||||
|
@ -53,7 +54,7 @@ class Field(object):
|
|||
return field_type.get_object_type(schema)
|
||||
if _is_class and issubclass(field_type, BaseObjectType):
|
||||
return field_type
|
||||
elif isinstance(field_type, basestring):
|
||||
elif isinstance(field_type, six.string_types):
|
||||
if field_type == 'self':
|
||||
return self.object_type
|
||||
else:
|
||||
|
@ -84,7 +85,7 @@ class Field(object):
|
|||
'Field could not be constructed in a non graphene.Type or graphene.Interface')
|
||||
|
||||
extra_args = self.extra_args.copy()
|
||||
for arg_name, arg_value in extra_args.items():
|
||||
for arg_name, arg_value in self.extra_args.items():
|
||||
if isinstance(arg_value, GraphQLArgument):
|
||||
self.args[arg_name] = arg_value
|
||||
del extra_args[arg_name]
|
||||
|
|
|
@ -103,9 +103,9 @@ class BaseObjectType(object):
|
|||
return None
|
||||
elif type(instance) is cls:
|
||||
instance = instance.instance
|
||||
return super(BaseObjectType, cls).__new__(cls, instance, *args, **kwargs)
|
||||
return super(BaseObjectType, cls).__new__(cls, *args, **kwargs)
|
||||
|
||||
def __init__(self, instance=None):
|
||||
def __init__(self, instance):
|
||||
signals.pre_init.send(self.__class__, instance=instance)
|
||||
self.instance = instance
|
||||
signals.post_init.send(self.__class__, instance=self)
|
||||
|
|
|
@ -33,7 +33,6 @@ def test_client_get_no_query(settings, client):
|
|||
def test_client_post_no_query(settings, client):
|
||||
settings.ROOT_URLCONF = 'tests.contrib_django.test_urls'
|
||||
response = client.post('/graphql', {})
|
||||
print response.content
|
||||
json_response = format_response(response)
|
||||
assert json_response == {'errors': [{'message': 'Must provide query string.'}]}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user