Skip to content

Commit edaf2a6

Browse files
committed
Merge branch 'feat-export-connection-field'
2 parents 760d001 + 8fa5501 commit edaf2a6

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ from graphene_mongo import MongoengineObjectType
3535
from .models import User as UserModel
3636

3737
class User(MongoengineObjectType):
38-
class Meta:
39-
model = UserModel
38+
class Meta:
39+
model = UserModel
4040

4141
class Query(graphene.ObjectType):
4242
users = graphene.List(User)

graphene_mongo/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#from .fields import (
2-
# MongoEngineDocumentField
3-
#)
1+
from .fields import (
2+
MongoengineConnectionField
3+
)
44

55
from .types import (
66
MongoengineObjectType,

graphene_mongo/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def merge_querysets(cls, default_queryset, queryset):
6767
def connection_resolver(cls, resolver, connection, model, root, info, **args):
6868
iterable = resolver(root, info, **args)
6969
if not iterable:
70-
interable = cls.get_query(model, info, **args)
70+
iterable = cls.get_query(model, info, **args)
7171
_len = len(iterable)
7272
connection = connection_from_list_slice(
7373
iterable,

graphene_mongo/tests/test_converter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from .models import Article, Editor, EmbeddedArticle, Reporter
1111

1212
from ..converter import convert_mongoengine_field
13-
from ..fields import MongoengineConnectionField
1413
from ..types import MongoengineObjectType
1514

1615

graphene_mongo/tests/test_query.py

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,51 @@ def resolve_reporter(self, *args, **kwargs):
180180
assert not result.errors
181181
assert dict(result.data['reporter']) == expected['reporter']
182182

183-
# TODO:
184-
def test_should_custom_identifier():
185-
pass
183+
def test_should_connection_field():
184+
class EditorNode(MongoengineObjectType):
185+
186+
class Meta:
187+
model = Editor
188+
interfaces = (Node,)
189+
190+
class Query(graphene.ObjectType):
191+
node = Node.Field()
192+
all_editors = MongoengineConnectionField(EditorNode)
193+
194+
query = '''
195+
query EditorQuery {
196+
allEditors {
197+
edges {
198+
node {
199+
firstName,
200+
lastName
201+
}
202+
}
203+
}
204+
}
205+
'''
206+
expected = {
207+
'allEditors': {
208+
'edges': [
209+
{
210+
'node': {
211+
'firstName': 'Penny',
212+
'lastName': 'Hardaway'
213+
},
214+
},
215+
{
216+
'node': {
217+
'firstName': 'Grant',
218+
'lastName': 'Hill'
219+
}
220+
}
221+
]
222+
}
223+
}
224+
schema = graphene.Schema(query=Query)
225+
result = schema.execute(query)
226+
assert not result.errors
227+
assert dict(result.data['allEditors']) == expected['allEditors']
186228

187229
# TODO:
188230
def test_should_mutate_well():

0 commit comments

Comments
 (0)