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