Skip to content

Commit c17b88a

Browse files
author
Ernesto Perez Amigo
committed
Optimizing imports, fix some minors bugs and working on performance
1 parent dbbfa33 commit c17b88a

14 files changed

+119
-200
lines changed

LICENSE

-21
This file was deleted.

MANIFEST.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
include README.md
2-
include README.rst
3-
recursive-exclude .vscode *
2+
include README.rst

README.md

+26-24
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ pip install graphene-django-extras
2828
1. DjangoSerializerMutation
2929

3030
**Types:**
31-
1. DjangoObjectTypeExtra
32-
2. DjangoInputObjectType
33-
3. DjangoPaginatedObjectListType
31+
1. DjangoObjectType
32+
2. DjangoListObjectType
33+
3. DjangoInputObjectType
3434

3535
**Pagination:**
3636
1. LimitOffsetGraphqlPagination
3737
2. PageGraphqlPagination
38-
3. CursosGraphqlPagination *(cooming soon)*
38+
3. CursorGraphqlPagination *(cooming soon)*
3939

4040

4141
### Examples
@@ -46,16 +46,16 @@ Here is a use of graphene-django-extras:
4646

4747
```python
4848
from django.contrib.auth.models import User
49-
from graphene_django_extras import DjangoObjectType, DjangoPaginatedObjectListType
49+
from graphene_django_extras import DjangoObjectType, DjangoListObjectType
5050
from graphene_django_extras.pagination import LimitOffsetGraphqlPagination
5151

5252
class UserType(DjangoObjectType):
5353
"""
54-
This DjangoObjectType have a ID field to filter to avoid resolve method definition on Queries
54+
This DjangoObjectType have a ID field, that allow filter by id and resolve method definition on Queries is not necesary
5555
"""
5656
class Meta:
5757
model = User
58-
description = "Type for User Model"
58+
description = " Type definition for single User model object "
5959
filter_fields = {
6060
'id': ['exact', ],
6161
'first_name': ['icontains', 'iexact'],
@@ -65,9 +65,9 @@ class UserType(DjangoObjectType):
6565
}
6666

6767

68-
class UserListType(DjangoPaginatedObjectListType):
68+
class UserListType(DjangoListObjectType):
6969
class Meta:
70-
description = "User list query definition"
70+
description = " Type definition for List of users "
7171
model = User
7272
pagination = LimitOffsetGraphqlPagination(page_size=20)
7373
```
@@ -79,15 +79,15 @@ from graphene_django_extras import DjangoInputObjectType
7979

8080
class UserInput(DjangoInputObjectType):
8181
class Meta:
82-
description = " Input Type for User Model "
82+
description = " User Input Type for used as input on Argumments classes on traditional Mutations "
8383
model = User
8484
```
8585

8686
#### 3- You can define traditional mutations that use Input Types or Mutations based on DRF SerializerClass:
8787

8888
```python
8989
import graphene
90-
from graphene_django_extras import DjangoSerializerMutation
90+
from graphene_django_extras import DjangoSerializerMutation
9191

9292
from .serializers import UserSerializer
9393
from .types import UserType
@@ -104,7 +104,7 @@ class UserSerializerMutation(DjangoSerializerMutation):
104104

105105
class UserMutation(graphene.mutation):
106106
"""
107-
You must implement the mutate function
107+
On traditional graphene mutation classes definition you must implement the mutate function
108108
"""
109109

110110
user = graphene.Field(UserType, required=False)
@@ -113,7 +113,7 @@ class UserMutation(graphene.mutation):
113113
new_user = graphene.Argument(UserInput)
114114

115115
class Meta:
116-
description = "Normal mutation for Users"
116+
description = " Traditional graphene mutation for Users "
117117

118118
@classmethod
119119
def mutate(cls, info, **kwargs):
@@ -130,14 +130,16 @@ from .mutations import UserMutation, UserSerializerMutation
130130

131131
class Queries(graphene.ObjectType):
132132
# Posible User list queries definitions
133-
all_users = DjangoListObjectField(UserListType, description=_('All Usersquery'))
133+
all_users = DjangoListObjectField(UserListType, description=_('All Users query'))
134134
all_users1 = DjangoFilterPaginateListField(UserType, pagination=LimitOffsetGraphqlPagination())
135135
all_users2 = DjangoFilterListField(UserType)
136136
all_users3 = DjangoListObjectField(UserListType, filterset_class=UserFilter, description=_('All Users query'))
137137

138-
# Single user queries definitions
139-
user = DjangoObjectField(UserType, description=_('Single User query'))
140-
other_way_user = DjangoObjectField(UserListType.getOne(), description=_('Other way to query a single User query'))
138+
# Defining the petition to a user
139+
user = DjangoObjectField(UserType, description=_('Single User query'))
140+
141+
# Another way to define a single user query
142+
other_way_user = DjangoObjectField(UserListType.getOne(), description=_('User List with pagination and filtering'))
141143

142144
class Mutations(graphene.ObjectType):
143145
user_create = UserSerializerMutation.CreateField(deprecation_reason='Deprecation message')
@@ -159,21 +161,21 @@ class Mutations(graphene.ObjectType):
159161
}
160162
totalCount
161163
}
162-
164+
163165
allUsers1(lastName_Iexact:"Doe", limit:5, offset:0){
164166
id
165167
username
166168
firstName
167-
lastName
169+
lastName
168170
}
169-
171+
170172
allUsers2(firstName_Icontains: "J"){
171173
id
172174
username
173175
firstName
174176
lastName
175177
}
176-
178+
177179
user(id:2){
178180
id
179181
username
@@ -186,7 +188,7 @@ class Mutations(graphene.ObjectType):
186188

187189
```js
188190
mutation{
189-
userCreate(newUser:{password:"test*123", email: "test@test.com", username:"test"}){
191+
userCreate(newUser:{username:"test", password:"test*123"}){
190192
user{
191193
id
192194
username
@@ -199,15 +201,15 @@ mutation{
199201
messages
200202
}
201203
}
202-
204+
203205
userDelete(id:1){
204206
ok
205207
errors{
206208
field
207209
messages
208210
}
209211
}
210-
212+
211213
userUpdate(newUser:{id:1, username:"John"}){
212214
user{
213215
id

README.rst

+18-16
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ Extra functionalities:
2929

3030
Types:
3131
1. DjangoObjectTypeExtra
32-
2. DjangoInputObjectType
33-
3. DjangoPaginatedObjectListType
32+
2. DjangoListObjectType
33+
3. DjangoInputObjectType
3434

3535
Pagination:
3636
1. LimitOffsetGraphqlPagination
3737
2. PageGraphqlPagination
38-
3. CursosGraphqlPagination (cooming soon)
38+
3. CursorGraphqlPagination (cooming soon)
3939

4040
Examples:
4141
---------
@@ -47,17 +47,17 @@ Here is a simple use of graphene-django-extras:
4747
.. code:: python
4848
4949
from django.contrib.auth.models import User
50-
from graphene_django_extras import DjangoObjectType, DjangoPaginatedObjectListType
50+
from graphene_django_extras import DjangoObjectType, DjangoListObjectType
5151
from graphene_django_extras.pagination import LimitOffsetGraphqlPagination
5252
5353
class UserType(DjangoObjectType):
5454
"""
55-
The DjangoObjectType have a ID field to filter to avoid resolve method definition on Queries
55+
This DjangoObjectType have a ID field, that allow filter by id and resolve method definition on Queries is not necesary
5656
"""
5757
5858
class Meta:
5959
model = User
60-
description = "Type for User Model"
60+
description = " Type definition for single User model object "
6161
filter_fields = {
6262
'id': ['exact', ],
6363
'first_name': ['icontains', 'iexact'],
@@ -66,9 +66,9 @@ Here is a simple use of graphene-django-extras:
6666
'email': ['icontains', 'iexact']
6767
}
6868
69-
class UserListType(DjangoPaginatedObjectListType):
69+
class UserListType(DjangoListObjectType):
7070
class Meta:
71-
description = "User list query definition"
71+
description = " Type definition for List of users "
7272
model = User
7373
pagination = LimitOffsetGraphqlPagination()
7474
@@ -81,7 +81,7 @@ Here is a simple use of graphene-django-extras:
8181
8282
class UserInput(DjangoInputObjectType):
8383
class Meta:
84-
description = " Input Type for User Model "
84+
description = " User Input Type for used as input on Argumments classes on traditional Mutations "
8585
model = User
8686
8787
@@ -91,7 +91,7 @@ Here is a simple use of graphene-django-extras:
9191
9292
import graphene
9393
from .serializers import UserSerializer
94-
from graphene_django_extras import DjangoSerializerMutation
94+
from graphene_django_extras import DjangoSerializerMutation
9595
from .types import UserType
9696
from .input_types import UserInputType
9797
@@ -103,7 +103,7 @@ Here is a simple use of graphene-django-extras:
103103
104104
class UserMutation(graphene.mutation):
105105
"""
106-
You must implement the mutate function
106+
On traditional graphene mutation classes definition you must implement the mutate function
107107
"""
108108
109109
user = graphene.Field(UserType, required=False)
@@ -112,7 +112,7 @@ Here is a simple use of graphene-django-extras:
112112
new_user = graphene.Argument(UserInput)
113113
114114
class Meta:
115-
description = "Normal mutation for Users"
115+
description = " Traditional graphene mutation for Users "
116116
117117
@classmethod
118118
def mutate(cls, info, **kwargs):
@@ -130,14 +130,16 @@ Here is a simple use of graphene-django-extras:
130130
131131
class Queries(graphene.ObjectType):
132132
# Posible User list queries definitions
133-
all_users = DjangoListObjectField(UserListType, description=_('All Usersquery'))
133+
all_users = DjangoListObjectField(UserListType, description=_('All Users query'))
134134
all_users1 = DjangoFilterPaginateListField(UserType, pagination=LimitOffsetGraphqlPagination())
135135
all_users2 = DjangoFilterListField(UserType)
136136
all_users3 = DjangoListObjectField(UserListType, filterset_class=UserFilter, description=_('All Users query'))
137137
138-
# Single user queries definitions
139-
user = DjangoObjectField(UserType, description=_('Single User query'))
140-
other_way_user = DjangoObjectField(UserListType.getOne(), description=_('Other way to query a single User query'))
138+
# Defining the petition to a user
139+
user = DjangoObjectField(UserType, description=_('Only one user'))
140+
141+
# Another way to define a single user query
142+
other_way_user = DjangoObjectField(UserListType.getOne(), description=_('User List with pagination and filtering'))
141143
142144
class Mutations(graphene.ObjectType):
143145
user_create = UserSerializerMutation.CreateField(deprecation_reason='Deprecation message')

graphene_django_extras/__init__.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# -*- coding: utf-8 -*-
22
from graphene import get_version
33

4-
from .fields import DjangoObjectField, DjangoListField, DjangoFilterListField, DjangoFilterPaginateListField, \
4+
from .fields import DjangoObjectField, DjangoFilterListField, DjangoFilterPaginateListField, \
55
DjangoListObjectField
66
from .mutation import DjangoSerializerMutation
77
from .pagination import LimitOffsetGraphqlPagination, PageGraphqlPagination, CursorGraphqlPagination
8-
from .types import DjangoObjectType, DjangoInputObjectType, DjangoPaginatedObjectListType
8+
from .types import DjangoObjectType, DjangoInputObjectType, DjangoListObjectType
99

10-
VERSION = (0, 0, 1, 'beta', 5)
10+
VERSION = (0, 0, 1, 'beta', 6)
1111

1212
__version__ = get_version(VERSION)
1313

@@ -16,7 +16,6 @@
1616

1717
# FIELDS
1818
'DjangoObjectField',
19-
'DjangoListField',
2019
'DjangoFilterListField',
2120
'DjangoFilterPaginateListField',
2221
'DjangoListObjectField',
@@ -31,6 +30,6 @@
3130

3231
# TYPES
3332
'DjangoObjectType',
34-
'DjangoInputObjectType',
35-
'DjangoPaginatedObjectListType',
33+
'DjangoListObjectType',
34+
'DjangoInputObjectType',
3635
)

0 commit comments

Comments
 (0)