Skip to content

Commit 99c3c43

Browse files
committed
feat: Rename graphene-mongoengine to graphene-mongo
1 parent bf73e6f commit 99c3c43

16 files changed

+71
-8
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.cache/
22
.eggs/
33
dist/
4-
graphene_mongoengine.egg-info/
4+
graphene_mongo.egg-info/
55
*.pyc
66
*.swp
77

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,64 @@
1-
# graphene-mongoengine
1+
# Graphene-Mongo
2+
3+
A [Mongoengine](https://mongoengine-odm.readthedocs.io/) integration for [Graphene](http://graphene-python.org/).
4+
5+
6+
## Installation
7+
8+
For instaling graphene, just run this command in your shell
9+
10+
```
11+
pip install graphene-mongo
12+
```
13+
14+
## Examples
15+
16+
Here is a simple Mongoengine model as `models.py`:
17+
18+
```python
19+
from mongoengine import Document
20+
from mongoengine.fields import StringField
21+
22+
class User(Document):
23+
24+
meta = {'collection': 'user'}
25+
first_name = StringField(required=True)
26+
last_name = StringField(required=True)
27+
```
28+
29+
To create a GraphQL schema for it you simply have to write the following:
30+
31+
```python
32+
import graphene
33+
34+
from graphene_mongo import MongoengineObjectType
35+
36+
from .models import User as UserModel
37+
38+
class User(MongoengineObjectType):
39+
class Meta:
40+
model = UserModel
41+
42+
class Query(graphene.ObjectType):
43+
users = graphene.List(User)
44+
45+
def resolve_users(self, info):
46+
return list(UserModel.objects.all())
47+
48+
schema = graphene.Schema(query=Query)
49+
```
50+
51+
Then you can simply query the schema:
52+
53+
```python
54+
query = '''
55+
query {
56+
users {
57+
firstName,
58+
lastName
59+
}
60+
}
61+
'''
62+
result = schema.execute(query)
63+
```
64+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

graphene_mongoengine/tests/models.py renamed to graphene_mongo/tests/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
MapField, ReferenceField, StringField
88
)
99

10-
connect('mongoenginetest', host='mongomock://localhost', alias='default')
10+
connect('graphene-mongo-test', host='mongomock://localhost', alias='default')
1111

1212

1313
class Editor(Document):
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)