Merge branch 'master' into feature/django

This commit is contained in:
Adam Charnock 2015-12-04 13:58:00 +00:00
commit 7d2ec21855
8 changed files with 62 additions and 21 deletions

View File

@ -14,8 +14,9 @@ cache:
- $HOME/docs/node_modules - $HOME/docs/node_modules
before_install: before_install:
- | - |
if [ "$TEST_TYPE" != build_website ] && \ git_diff=$(git diff --name-only $TRAVIS_COMMIT_RANGE)
! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs))/' if [ "$?" == 0 ] && [ "$TEST_TYPE" != build_website ] && \
! echo "$git_diff" | grep -qvE '(\.md$)|(^(docs))/'
then then
echo "Only docs were updated, stopping build process." echo "Only docs were updated, stopping build process."
exit exit

View File

@ -63,15 +63,15 @@ class Query(graphene.ObjectType):
@resolve_only_args @resolve_only_args
def resolve_ships(self): def resolve_ships(self):
return [Ship(s) for s in get_ships()] return get_ships()
@resolve_only_args @resolve_only_args
def resolve_rebels(self): def resolve_rebels(self):
return Faction(get_rebels()) return get_rebels()
@resolve_only_args @resolve_only_args
def resolve_empire(self): def resolve_empire(self):
return Faction(get_empire()) return get_empire()
class Mutation(graphene.ObjectType): class Mutation(graphene.ObjectType):

View File

@ -4,19 +4,13 @@ from graphql.core.type import (
from graphene import signals from graphene import signals
from graphene.core.schema import ( from .core import (
Schema Schema,
)
from graphene.core.classtypes import (
ObjectType, ObjectType,
InputObjectType, InputObjectType,
Interface, Interface,
Mutation, Mutation,
Scalar Scalar,
)
from graphene.core.types import (
BaseType, BaseType,
LazyType, LazyType,
Argument, Argument,

View File

@ -27,7 +27,7 @@ class ConnectionOrListField(Field):
if not field_object_type: if not field_object_type:
raise SkipField() raise SkipField()
if is_node(field_object_type): if is_node(field_object_type):
field = DjangoConnectionField(field_object_type) field = ConnectionField(field_object_type)
else: else:
field = Field(List(field_object_type)) field = Field(List(field_object_type))
field.contribute_to_class(self.object_type, self.attname) field.contribute_to_class(self.object_type, self.attname)

View File

@ -16,9 +16,6 @@ class Reporter(models.Model):
def __str__(self): # __unicode__ on Python 2 def __str__(self): # __unicode__ on Python 2
return "%s %s" % (self.first_name, self.last_name) return "%s %s" % (self.first_name, self.last_name)
class Meta:
app_label = 'contrib_django'
class Article(models.Model): class Article(models.Model):
headline = models.CharField(max_length=100) headline = models.CharField(max_length=100)
@ -30,4 +27,3 @@ class Article(models.Model):
class Meta: class Meta:
ordering = ('headline',) ordering = ('headline',)
app_label = 'contrib_django'

View File

@ -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']

View File

@ -63,6 +63,9 @@ class Field(OrderedType):
return NonNull(self.type) return NonNull(self.type)
return self.type return self.type
def decorate_resolver(self, resolver):
return snake_case_args(resolver)
def internal_type(self, schema): def internal_type(self, schema):
resolver = self.resolver resolver = self.resolver
description = self.description description = self.description
@ -85,9 +88,9 @@ class Field(OrderedType):
return my_resolver(instance, args, info) return my_resolver(instance, args, info)
resolver = wrapped_func resolver = wrapped_func
resolver = snake_case_args(resolver)
assert type, 'Internal type for field %s is None' % str(self) 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,) description=description,)
def __repr__(self): def __repr__(self):

View File

@ -1,6 +1,7 @@
SECRET_KEY = 1 SECRET_KEY = 1
INSTALLED_APPS = [ INSTALLED_APPS = [
'graphene.contrib.django.tests',
'examples.starwars_django', 'examples.starwars_django',
] ]