Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A [Mongoengine](https://mongoengine-odm.readthedocs.io/) integration for [Graphe

## Installation

For instaling graphene-mongo, just run this command in your shell
For installing graphene-mongo, just run this command in your shell

```
pip install graphene-mongo
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A `Mongoengine <https://mongoengine-odm.readthedocs.io/>`__ integration for `Gra
Installation
------------

For instaling graphene-mongo, just run this command in your shell
For installing graphene-mongo, just run this command in your shell

.. code:: bash

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Let's get start with following models:
Schema
------

Here I assume you guys have the basic knowledage of how schema works in GraphQL, that I define the *root type* as the `Query` class below with the ability to list all employees.
Here I assume you guys have the basic knowledge of how schema works in GraphQL, that I define the *root type* as the `Query` class below with the ability to list all employees.

.. code:: python

Expand Down
1 change: 0 additions & 1 deletion examples/flask_mongoengine/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@
if __name__ == '__main__':
init_db()
app.run()

4 changes: 3 additions & 1 deletion examples/flask_mongoengine/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from models import Role as RoleModel
from models import Task as TaskModel


class Department(MongoengineObjectType):

class Meta:
Expand All @@ -26,6 +27,7 @@ class Meta:
model = TaskModel
interfaces = (Node,)


class Employee(MongoengineObjectType):

class Meta:
Expand All @@ -39,5 +41,5 @@ class Query(graphene.ObjectType):
all_roles = MongoengineConnectionField(Role)
role = graphene.Field(Role)

schema = graphene.Schema(query=Query, types=[Department, Employee, Role])

schema = graphene.Schema(query=Query, types=[Department, Employee, Role])
10 changes: 1 addition & 9 deletions graphene_mongo/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Article(mongoengine.Document):
help_text="The date of first press.")
editor = mongoengine.ReferenceField(Editor)
reporter = mongoengine.ReferenceField('Reporter')
# Will not convert this field cause no chioces
# Will not convert this field cause no choices
generic_reference = mongoengine.GenericReferenceField()


Expand All @@ -68,14 +68,6 @@ class Reporter(mongoengine.Document):
articles = mongoengine.ListField(mongoengine.ReferenceField(Article))
embedded_articles = mongoengine.ListField(mongoengine.EmbeddedDocumentField(EmbeddedArticle))
embedded_list_articles = mongoengine.EmbeddedDocumentListField(EmbeddedArticle)
id = mongoengine.StringField(primary_key=True)
first_name = mongoengine.StringField(required=True)
last_name = mongoengine.StringField(required=True)
email = mongoengine.EmailField()
awards = mongoengine.ListField(mongoengine.StringField())
articles = mongoengine.ListField(mongoengine.ReferenceField(Article))
embedded_articles = mongoengine.ListField(mongoengine.EmbeddedDocumentField(EmbeddedArticle))
embedded_list_articles = mongoengine.EmbeddedDocumentListField(EmbeddedArticle)
generic_reference = mongoengine.GenericReferenceField(
choices=[Article, Editor, ]
)
Expand Down
5 changes: 2 additions & 3 deletions graphene_mongo/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):
exclude_fields ([str]):

Returns:
(OrderedDict, OrderedDict): coverted fields and self reference fields.
(OrderedDict, OrderedDict): converted fields and self reference fields.

"""
_model_fields = get_model_fields(model)
Expand Down Expand Up @@ -163,13 +163,12 @@ def rescan_fields(cls):

mongoengine_fields = yank_fields_from_attrs(converted_fields, _as=graphene.Field)

# The initial scan should take precidence
# The initial scan should take precedence
for field in mongoengine_fields:
if field not in cls._meta.fields:
cls._meta.fields.update({field: mongoengine_fields[field]})
# Self-referenced fields can't change between scans!


# noqa
@classmethod
def is_type_of(cls, root, info):
Expand Down