diff --git a/.travis.yml b/.travis.yml index fba19076..3319c5c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,9 @@ cache: - $HOME/docs/node_modules before_install: - | - if [ "$TEST_TYPE" != build_website ] && \ - ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs))/' + git_diff=$(git diff --name-only $TRAVIS_COMMIT_RANGE) + if [ "$?" == 0 ] && [ "$TEST_TYPE" != build_website ] && \ + ! echo "$git_diff" | grep -qvE '(\.md$)|(^(docs))/' then echo "Only docs were updated, stopping build process." exit diff --git a/examples/starwars_django/schema.py b/examples/starwars_django/schema.py index 501ccce6..88407103 100644 --- a/examples/starwars_django/schema.py +++ b/examples/starwars_django/schema.py @@ -63,15 +63,15 @@ class Query(graphene.ObjectType): @resolve_only_args def resolve_ships(self): - return [Ship(s) for s in get_ships()] + return get_ships() @resolve_only_args def resolve_rebels(self): - return Faction(get_rebels()) + return get_rebels() @resolve_only_args def resolve_empire(self): - return Faction(get_empire()) + return get_empire() class Mutation(graphene.ObjectType): diff --git a/graphene/__init__.py b/graphene/__init__.py index 88d3a365..88404d62 100644 --- a/graphene/__init__.py +++ b/graphene/__init__.py @@ -4,19 +4,13 @@ from graphql.core.type import ( from graphene import signals -from graphene.core.schema import ( - Schema -) - -from graphene.core.classtypes import ( +from .core import ( + Schema, ObjectType, InputObjectType, Interface, Mutation, - Scalar -) - -from graphene.core.types import ( + Scalar, BaseType, LazyType, Argument, diff --git a/graphene/contrib/django/fields.py b/graphene/contrib/django/fields.py index 16568883..85c0082f 100644 --- a/graphene/contrib/django/fields.py +++ b/graphene/contrib/django/fields.py @@ -27,7 +27,7 @@ class ConnectionOrListField(Field): if not field_object_type: raise SkipField() if is_node(field_object_type): - field = DjangoConnectionField(field_object_type) + field = ConnectionField(field_object_type) else: field = Field(List(field_object_type)) field.contribute_to_class(self.object_type, self.attname) diff --git a/graphene/contrib/django/tests/models.py b/graphene/contrib/django/tests/models.py index 172352e4..a4ff3386 100644 --- a/graphene/contrib/django/tests/models.py +++ b/graphene/contrib/django/tests/models.py @@ -16,9 +16,6 @@ class Reporter(models.Model): def __str__(self): # __unicode__ on Python 2 return "%s %s" % (self.first_name, self.last_name) - class Meta: - app_label = 'contrib_django' - class Article(models.Model): headline = models.CharField(max_length=100) @@ -30,4 +27,3 @@ class Article(models.Model): class Meta: ordering = ('headline',) - app_label = 'contrib_django' diff --git a/graphene/core/__init__.py b/graphene/core/__init__.py index e69de29b..d27a72bb 100644 --- a/graphene/core/__init__.py +++ b/graphene/core/__init__.py @@ -0,0 +1,46 @@ +from .schema import ( + Schema +) + +from .classtypes import ( + ObjectType, + InputObjectType, + Interface, + Mutation, + Scalar +) + +from .types import ( + BaseType, + LazyType, + Argument, + Field, + InputField, + String, + Int, + Boolean, + ID, + Float, + List, + NonNull +) + +__all__ = [ + 'Argument', + 'String', + 'Int', + 'Boolean', + 'Float', + 'ID', + 'List', + 'NonNull', + 'Schema', + 'BaseType', + 'LazyType', + 'ObjectType', + 'InputObjectType', + 'Interface', + 'Mutation', + 'Scalar', + 'Field', + 'InputField'] diff --git a/graphene/core/types/field.py b/graphene/core/types/field.py index d7643b5e..c3fa712f 100644 --- a/graphene/core/types/field.py +++ b/graphene/core/types/field.py @@ -63,6 +63,9 @@ class Field(OrderedType): return NonNull(self.type) return self.type + def decorate_resolver(self, resolver): + return snake_case_args(resolver) + def internal_type(self, schema): resolver = self.resolver description = self.description @@ -85,9 +88,9 @@ class Field(OrderedType): return my_resolver(instance, args, info) resolver = wrapped_func - resolver = snake_case_args(resolver) assert type, 'Internal type for field %s is None' % str(self) - return GraphQLField(type, args=schema.T(arguments), resolver=resolver, + return GraphQLField(type, args=schema.T(arguments), + resolver=self.decorate_resolver(resolver), description=description,) def __repr__(self): diff --git a/tests/django_settings.py b/tests/django_settings.py index 2af62bb3..998f68ab 100644 --- a/tests/django_settings.py +++ b/tests/django_settings.py @@ -1,6 +1,7 @@ SECRET_KEY = 1 INSTALLED_APPS = [ + 'graphene.contrib.django.tests', 'examples.starwars_django', ]