Skip to content

Commit b331319

Browse files
author
=
committed
Fix merge conflicts
2 parents 61829ab + a480a39 commit b331319

34 files changed

+749
-140
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install:
1111
pip install -e .[test]
1212
pip install psycopg2 # Required for Django postgres fields testing
1313
pip install django==$DJANGO_VERSION
14-
if [ $DJANGO_VERSION = 1.8 ]; then # DRF dropped 1.8 support at 3.7.0
14+
if (($(echo "$DJANGO_VERSION <= 1.9" | bc -l))); then # DRF dropped 1.8 and 1.9 support at 3.7.0
1515
pip install djangorestframework==3.6.4
1616
fi
1717
python setup.py develop

docs/authorization.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ define a resolve method for that field and return the desired queryset.
6161
from .models import Post
6262
6363
class Query(ObjectType):
64-
all_posts = DjangoFilterConnectionField(CategoryNode)
64+
all_posts = DjangoFilterConnectionField(PostNode)
6565
6666
def resolve_all_posts(self, args, info):
6767
return Post.objects.filter(published=True)
@@ -79,7 +79,7 @@ with the context argument.
7979
from .models import Post
8080
8181
class Query(ObjectType):
82-
my_posts = DjangoFilterConnectionField(CategoryNode)
82+
my_posts = DjangoFilterConnectionField(PostNode)
8383
8484
def resolve_my_posts(self, info):
8585
# context will reference to the Django request

docs/filtering.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,4 @@ pre-filter animals owned by the authenticated user (set in ``context.user``).
145145
@property
146146
def qs(self):
147147
# The query context can be found in self.request.
148-
return super(AnimalFilter, self).filter(owner=self.request.user)
148+
return super(AnimalFilter, self).qs.filter(owner=self.request.user)

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
sphinx
22
# Docs template
3-
https://github.com/graphql-python/graphene-python.org/archive/docs.zip
3+
http://graphene-python.org/sphinx_graphene_theme.zip

docs/rest-framework.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,50 @@ You can create a Mutation based on a serializer by using the
1919
class Meta:
2020
serializer_class = MySerializer
2121
22+
Create/Update Operations
23+
---------------------
24+
25+
By default ModelSerializers accept create and update operations. To
26+
customize this use the `model_operations` attribute. The update
27+
operation looks up models by the primary key by default. You can
28+
customize the look up with the lookup attribute.
29+
30+
Other default attributes:
31+
32+
`partial = False`: Accept updates without all the input fields.
33+
34+
.. code:: python
35+
36+
from graphene_django.rest_framework.mutation import SerializerMutation
37+
38+
class AwesomeModelMutation(SerializerMutation):
39+
class Meta:
40+
serializer_class = MyModelSerializer
41+
model_operations = ['create', 'update']
42+
lookup_field = 'id'
43+
44+
Overriding Update Queries
45+
-------------------------
46+
47+
Use the method `get_serializer_kwargs` to override how
48+
updates are applied.
49+
50+
.. code:: python
51+
52+
from graphene_django.rest_framework.mutation import SerializerMutation
53+
54+
class AwesomeModelMutation(SerializerMutation):
55+
class Meta:
56+
serializer_class = MyModelSerializer
57+
58+
@classmethod
59+
def get_serializer_kwargs(cls, root, info, **input):
60+
if 'id' in input:
61+
instance = Post.objects.filter(id=input['id'], owner=info.context.user).first()
62+
if instance:
63+
return {'instance': instance, 'data': input, 'partial': True}
64+
65+
else:
66+
raise http.Http404
67+
68+
return {'data': input, 'partial': True}

docs/tutorial-plain.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ Let's get started with these models:
6868
class Ingredient(models.Model):
6969
name = models.CharField(max_length=100)
7070
notes = models.TextField()
71-
category = models.ForeignKey(Category, related_name='ingredients')
71+
category = models.ForeignKey(Category, related_name='ingredients',
72+
on_delete=models.CASCADE)
7273
7374
def __str__(self):
7475
return self.name
@@ -80,7 +81,7 @@ Add ingredients as INSTALLED_APPS:
8081
INSTALLED_APPS = [
8182
...
8283
# Install the ingredients app
83-
'ingredients',
84+
'cookbook.ingredients',
8485
]
8586
8687
Don't forget to create & run migrations:

docs/tutorial-relay.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
118118
.. code:: python
119119
120120
# cookbook/ingredients/schema.py
121-
from graphene import relay, ObjectType, AbstractType
121+
from graphene import relay, ObjectType
122122
from graphene_django import DjangoObjectType
123123
from graphene_django.filter import DjangoFilterConnectionField
124124
@@ -147,7 +147,7 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
147147
interfaces = (relay.Node, )
148148
149149
150-
class Query(AbstractType):
150+
class Query(object):
151151
category = relay.Node.Field(CategoryNode)
152152
all_categories = DjangoFilterConnectionField(CategoryNode)
153153

examples/cookbook-plain/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#testing-our-graphql-schema)
63+
(See the [Graphene-Django Tutorial](http://docs.graphene-python.org/projects/django/en/latest/tutorial-plain/#testing-our-graphql-schema)
6464
for some example queries)

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#testing-our-graphql-schema)
63+
(See the [Graphene-Django Tutorial](http://docs.graphene-python.org/projects/django/en/latest/tutorial-plain/#testing-our-graphql-schema)
6464
for some example queries)

graphene_django/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
DjangoConnectionField,
66
)
77

8-
__version__ = '2.0.0'
8+
__version__ = '2.0.1'
99

1010
__all__ = [
1111
'__version__',

0 commit comments

Comments
 (0)