Skip to content

Commit e77962b

Browse files
authored
Merge pull request #1 from nickhudkins/recursive-nodes
Bring up to date with upstream master
2 parents 207f4eb + 0200b32 commit e77962b

File tree

19 files changed

+92
-157
lines changed

19 files changed

+92
-157
lines changed

.travis.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ python:
66
- 3.5
77
- pypy
88
before_install:
9-
- |
10-
if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then
11-
export PYENV_ROOT="$HOME/.pyenv"
12-
if [ -f "$PYENV_ROOT/bin/pyenv" ]; then
13-
cd "$PYENV_ROOT" && git pull
14-
else
15-
rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT"
16-
fi
17-
export PYPY_VERSION="4.0.1"
18-
"$PYENV_ROOT/bin/pyenv" install "pypy-$PYPY_VERSION"
19-
virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION"
20-
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
21-
fi
9+
- |
10+
if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then
11+
export PYENV_ROOT="$HOME/.pyenv"
12+
if [ -f "$PYENV_ROOT/bin/pyenv" ]; then
13+
cd "$PYENV_ROOT" && git pull
14+
else
15+
rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT"
16+
fi
17+
export PYPY_VERSION="4.0.1"
18+
"$PYENV_ROOT/bin/pyenv" install "pypy-$PYPY_VERSION"
19+
virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION"
20+
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
21+
fi
2222
install:
2323
- |
2424
if [ "$TEST_TYPE" = build ]; then
@@ -45,7 +45,7 @@ after_success:
4545
fi
4646
env:
4747
matrix:
48-
- TEST_TYPE=build
48+
- TEST_TYPE=build DJANGO_VERSION=1.10
4949
matrix:
5050
fast_finish: true
5151
include:
@@ -59,3 +59,10 @@ matrix:
5959
env: TEST_TYPE=build DJANGO_VERSION=1.9
6060
- python: '2.7'
6161
env: TEST_TYPE=lint
62+
deploy:
63+
provider: pypi
64+
user: syrusakbary
65+
on:
66+
tags: true
67+
password:
68+
secure: kymIFCEPUbkgRqe2NAXkWfxMmGRfWvWBOP6LIXdVdkOOkm91fU7bndPGrAjos+/7gN0Org609ZmHSlVXNMJUWcsL2or/x5LcADJ4cZDe+79qynuoRb9xs1Ri4O4SBAuVMZxuVJvs8oUzT2R11ql5vASSMtXgbX+ZDGpmPRVZStkCuXgOc4LBhbPKyl3OFy7UQFPgAEmy3Yjh4ZSKzlXheK+S6mmr60+DCIjpaA0BWPxYK9FUE0qm7JJbHLUbwsUP/QMp5MmGjwFisXCNsIe686B7QKRaiOw62eJc2R7He8AuEC8T9OM4kRwDlecSn8mMpkoSB7QWtlJ+6XdLrJFPNvtrOfgfzS9/96Qrw9WlOslk68hMlhJeRb0s2YUD8tiV3UUkvbL1mfFoS4SI9U+rojS55KhUEJWHg1w7DjoOPoZmaIL2ChRupmvrFYNAGae1cxwG3Urh+t3wYlN3gpKsRDe5GOT7Wm2tr0ad3McCpDGUwSChX59BAJXe/MoLxkKScTrMyR8yMxHOF0b4zpVn5l7xB/o2Ik4zavx5q/0rGBMK2D+5d+gpQogKShoquTPsZUwO7sB5hYeH2hqGqpeGzZtb76E2zZYd18pJ0FsBudm5+KWjYdZ+vbtGrLxdTXJ1EEtzVXm0lscykTpqUucbXSa51dhStJvW2xEEz6p3rHo=

docs/authorization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Let's use a simple example model.
1212
from django.db import models
1313
1414
class Post(models.Model):
15-
name = models.CharField(max_length=100)
15+
title = models.CharField(max_length=100)
1616
content = models.TextField()
1717
published = models.BooleanField(default=False)
1818
owner = models.ForeignKey('auth.User')

docs/filtering.rst

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -91,50 +91,13 @@ Which you could query as follows:
9191
}
9292
}
9393
94-
Orderable fields
95-
----------------
96-
97-
Ordering can also be specified using ``filter_order_by``. Like
98-
``filter_fields``, this value is also passed directly to
99-
``django-filter`` as the ``order_by`` field. For full details see the
100-
`order\_by
101-
documentation <https://django-filter.readthedocs.org/en/latest/usage.html#ordering-using-order-by>`__.
102-
103-
For example:
104-
105-
.. code:: python
106-
107-
class AnimalNode(DjangoObjectType):
108-
class Meta:
109-
model = Animal
110-
filter_fields = ['name', 'genus', 'is_domesticated']
111-
# Either a tuple/list of fields upon which ordering is allowed, or
112-
# True to allow filtering on all fields specified in filter_fields
113-
filter_order_by = True
114-
interfaces = (relay.Node, )
115-
116-
You can then control the ordering via the ``orderBy`` argument:
117-
118-
.. code::
119-
120-
query {
121-
allAnimals(orderBy: "name") {
122-
edges {
123-
node {
124-
id,
125-
name
126-
}
127-
}
128-
}
129-
}
130-
13194
Custom Filtersets
13295
-----------------
13396

13497
By default Graphene provides easy access to the most commonly used
13598
features of ``django-filter``. This is done by transparently creating a
13699
``django_filters.FilterSet`` class for you and passing in the values for
137-
``filter_fields`` and ``filter_order_by``.
100+
``filter_fields``.
138101

139102
However, you may find this to be insufficient. In these cases you can
140103
create your own ``Filterset`` as follows:

docs/tutorial.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ We will setup the project, create the following:
3131
3232
# Set up a new project with a single application
3333
django-admin.py startproject cookbook . # Note the trailing '.' character
34+
cd cookbook
3435
django-admin.py startapp ingredients
3536
3637
Now sync your database for the first time:
@@ -98,7 +99,6 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
9899
class Meta:
99100
model = Category
100101
filter_fields = ['name', 'ingredients']
101-
filter_order_by = ['name']
102102
interfaces = (relay.Node, )
103103
104104
@@ -112,7 +112,6 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
112112
'category': ['exact'],
113113
'category__name': ['exact'],
114114
}
115-
filter_order_by = ['name', 'category__name']
116115
interfaces = (relay.Node, )
117116
118117

examples/cookbook/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ Now you should be ready to start the server:
6060
Now head on over to
6161
[http://127.0.0.1:8000/graphql](http://127.0.0.1:8000/graphql)
6262
and run some queries!
63-
(See the [Graphene-Django Tutorial](http://docs.graphene-python.org/projects/django/en/latest/tutorial.html#testing-our-graphql-schema)
63+
(See the [Graphene-Django Tutorial](http://docs.graphene-python.org/projects/django/en/latest/tutorial#testing-our-graphql-schema)
6464
for some example queries)

examples/cookbook/cookbook/ingredients/schema.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class Meta:
1212
model = Category
1313
interfaces = (Node, )
1414
filter_fields = ['name', 'ingredients']
15-
filter_order_by = ['name']
1615

1716

1817
class IngredientNode(DjangoObjectType):
@@ -27,7 +26,6 @@ class Meta:
2726
'category': ['exact'],
2827
'category__name': ['exact'],
2928
}
30-
filter_order_by = ['name', 'category__name']
3129

3230

3331
class Query(AbstractType):

examples/cookbook/cookbook/recipes/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Meta:
99
model = Recipe
1010
interfaces = (Node, )
1111
filter_fields = ['title','amounts']
12-
filter_order_by = ['title']
12+
1313

1414
class RecipeIngredientNode(DjangoObjectType):
1515

@@ -22,7 +22,7 @@ class Meta:
2222
'recipe': ['exact'],
2323
'recipe__title': ['icontains'],
2424
}
25-
filter_order_by = ['ingredient__name', 'recipe__title',]
25+
2626

2727
class Query(AbstractType):
2828
recipe = Node.Field(RecipeNode)

graphene_django/compat.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class MissingType(object):
55
pass
66

7+
78
try:
89
DurationField = models.DurationField
910
UUIDField = models.UUIDField
@@ -21,6 +22,13 @@ class MissingType(object):
2122

2223
try:
2324
# Postgres fields are only available in Django 1.8+
24-
from django.contrib.postgres.fields import ArrayField, HStoreField, JSONField, RangeField
25+
from django.contrib.postgres.fields import ArrayField, HStoreField, RangeField
2526
except ImportError:
2627
ArrayField, HStoreField, JSONField, RangeField = (MissingType, ) * 4
28+
29+
30+
try:
31+
# Postgres fields are only available in Django 1.9+
32+
from django.contrib.postgres.fields import JSONField
33+
except ImportError:
34+
JSONField = MissingType

graphene_django/converter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from graphene import (ID, Boolean, Dynamic, Enum, Field, Float, Int, List,
55
NonNull, String)
66
from graphene.relay import is_node
7-
from graphene.types.datetime import DateTime
7+
from graphene.types.datetime import DateTime, Time
88
from graphene.types.json import JSONString
9-
from graphene.utils.str_converters import to_const
9+
from graphene.utils.str_converters import to_camel_case, to_const
1010
from graphql import assert_valid_name
1111

1212
from .compat import (ArrayField, HStoreField, JSONField, RangeField,
@@ -41,7 +41,7 @@ def convert_django_field_with_choices(field, registry=None):
4141
choices = getattr(field, 'choices', None)
4242
if choices:
4343
meta = field.model._meta
44-
name = '{}{}'.format(meta.object_name, field.name.capitalize())
44+
name = to_camel_case('{}_{}'.format(meta.object_name, field.name))
4545
choices = list(get_choices(choices))
4646
named_choices = [(c[0], c[1]) for c in choices]
4747
named_choices_descriptions = {c[0]: c[2] for c in choices}
@@ -112,6 +112,11 @@ def convert_date_to_string(field, registry=None):
112112
return DateTime(description=field.help_text, required=not field.null)
113113

114114

115+
@convert_django_field.register(models.TimeField)
116+
def convert_time_to_string(field, registry=None):
117+
return Time(description=field.help_text, required=not field.null)
118+
119+
115120
@convert_django_field.register(models.OneToOneRel)
116121
def convert_onetoone_field_to_djangomodel(field, registry=None):
117122
model = get_related_model(field)

graphene_django/filter/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
)
99
else:
1010
from .fields import DjangoFilterConnectionField
11-
from .filterset import GrapheneFilterSet, GlobalIDFilter, GlobalIDMultipleChoiceFilter
11+
from .filterset import GlobalIDFilter, GlobalIDMultipleChoiceFilter
1212

13-
__all__ = ['DjangoFilterConnectionField', 'GrapheneFilterSet',
13+
__all__ = ['DjangoFilterConnectionField',
1414
'GlobalIDFilter', 'GlobalIDMultipleChoiceFilter']

0 commit comments

Comments
 (0)