Graphene-Mongo
A Mongoengine integration for Graphene.
Installation
For installing graphene-mongo, just run this command in your shell
pip install graphene-mongo
Examples
Here is a simple Mongoengine model as models.py:
from mongoengine import Document
from mongoengine.fields import StringField
class User(Document):
meta = {'collection': 'user'}
first_name = StringField(required=True)
last_name = StringField(required=True)
To create a GraphQL schema and sync executor; for it you simply have to write the following:
import graphene
from graphene_mongo import MongoengineObjectType
from .models import User as UserModel
class User(MongoengineObjectType):
class Meta:
model = UserModel
class Query(graphene.ObjectType):
users = graphene.List(User)
def resolve_users(self, info):
return list(UserModel.objects.all())
schema = graphene.Schema(query=Query)
Then you can simply query the schema:
query = '''
query {
users {
firstName,
lastName
}
}
'''
result = await schema.execute(query)
To create a GraphQL schema and async executor; for it you simply have to write the following:
import graphene
from graphene_mongo import AsyncMongoengineObjectType
from graphene_mongo.utils import sync_to_async
from concurrent.futures import ThreadPoolExecutor
from .models import User as UserModel
class User(AsyncMongoengineObjectType):
class Meta:
model = UserModel
class Query(graphene.ObjectType):
users = graphene.List(User)
async def resolve_users(self, info):
return await sync_to_async(list, thread_sensitive=False,
executor=ThreadPoolExecutor())(UserModel.objects.all())
schema = graphene.Schema(query=Query)
Then you can simply query the schema:
query = '''
query {
users {
firstName,
lastName
}
}
'''
result = await schema.execute_async(query)
To learn more check out the following examples:
Contributing
After cloning this repo, ensure dependencies are installed by running:
pip install -r requirements.txt
After developing, the full test suite can be evaluated by running:
make test
Metadata
Release files for graphene-mongo 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| graphene_mongo-0.4.5.tar.gz | 20.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| graphene_mongo-0.4.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.1 kB
Release files / graphene_mongo-0.4.5.tar.gz
| Download URL | graphene_mongo-0.4.5.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aab35d29032228f2cbc22048e462ab43b356f5f1724ae17f0295be048b0bda3a
|
|
BLAKE2b-256 checksum How to use checksums |
b2b4b7790abd2bd5c6b4b512cec7b36814a62c93a66cda462afa2c4632ed459f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 3, 2026.
Transparency logRelease files / graphene_mongo-0.4.5-py3-none-any.whl
| Download URL | graphene_mongo-0.4.5-py3-none-any.whl |
|---|---|
| Size | 29.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c1528cea7d95a49303505f5cd4f7dc68a2d1936a1589b28d5380873afe37590
|
|
BLAKE2b-256 checksum How to use checksums |
4f91ecc339af039c63a217de2cdb33419c6dad92668c54492dcb5e4033873408
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 3, 2026.
Transparency log