Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(async) - Improvement #219

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d273922
Fix(register): updated register_enum function support custom classes
AdithyanJothir Apr 5, 2023
b9a1f24
Merge pull request #4 from AdithyanJothir/master
adarshdigievo Apr 5, 2023
ec1c7af
Merge branch 'graphql-python:master' into master
arun-sureshkumar Apr 9, 2023
81746fb
Support Async
arunsureshkumar Apr 9, 2023
e225c5c
Convert: get_node to async
arunsureshkumar Apr 11, 2023
1f0250b
Merge branch 'graphql-python:master' into master
arunsureshkumar Apr 11, 2023
adec7f5
Merge remote-tracking branch 'origin/master' into feat(async)
arunsureshkumar Apr 11, 2023
ec3e60e
Fix: Test Case
arunsureshkumar Apr 11, 2023
5ff73e6
Bug Fix on connection_resolver
arunsureshkumar Apr 11, 2023
d473b11
Support Async
arunsureshkumar Apr 11, 2023
7c99bc1
Fix: connection_resolver
arunsureshkumar Apr 11, 2023
2fe5008
Support Async, Test Case Added
arunsureshkumar Apr 11, 2023
9581ad2
Bump Version : 0.4.0
arunsureshkumar Apr 11, 2023
6eb5d23
Merge remote-tracking branch 'origin/v0.4.0' into feat(async)
arunsureshkumar Apr 11, 2023
c5b71cf
Add asgiref to dependency
arunsureshkumar Apr 11, 2023
e5bb865
Add pytest-asyncio to dependency
arunsureshkumar Apr 11, 2023
3d183f8
Fix: Test Case
arunsureshkumar Apr 11, 2023
254cb7d
Update: README.md
arunsureshkumar Apr 11, 2023
55d9eb6
Blocking Threaded to Async
arunsureshkumar Apr 12, 2023
2b2813d
Bug Fix: Argument Parser
arunsureshkumar Apr 12, 2023
f171ddd
(Deprecated) get_resolver to wrap_resolve
arunsureshkumar Apr 12, 2023
f4a2037
Fix: Count Performance
arunsureshkumar Apr 12, 2023
ec75d29
Fix: Queryset Check
arunsureshkumar Apr 24, 2023
67de479
Optimise: Lazy Reference Resolver
arunsureshkumar Apr 28, 2023
d1d60b9
Fix: DeprecationWarnings
arunsureshkumar Apr 30, 2023
60f2273
Fix: Queryset evaluation
arunsureshkumar May 6, 2023
9be137c
feat: add support for mongo date field
mak626 Aug 1, 2023
cb56602
Merge pull request #7 from mak626/date-field-support
abhinand-c Aug 1, 2023
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
54 changes: 49 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

A [Mongoengine](https://mongoengine-odm.readthedocs.io/) integration for [Graphene](http://graphene-python.org/).


## Installation

For installing graphene-mongo, just run this command in your shell
Expand All @@ -23,13 +22,14 @@ 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 for it you simply have to write the following:
To create a GraphQL schema and sync executor; for it you simply have to write the following:

```python
import graphene
Expand All @@ -38,15 +38,60 @@ 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())
return list(UserModel.objects.all())


schema = graphene.Schema(query=Query)
```

Then you can simply query the schema:

```python
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:

```python
import graphene

from graphene_mongo import AsyncMongoengineObjectType
from asgiref.sync 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)
```
Expand All @@ -71,7 +116,6 @@ To learn more check out the following [examples](examples/):
* [Django MongoEngine example](examples/django_mongoengine)
* [Falcon MongoEngine example](examples/falcon_mongoengine)


## Contributing

After cloning this repo, ensure dependencies are installed by running:
Expand Down
8 changes: 6 additions & 2 deletions graphene_mongo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from .fields import MongoengineConnectionField
from .fields_async import AsyncMongoengineConnectionField

from .types import MongoengineObjectType, MongoengineInputType, MongoengineInterfaceType
from .types_async import AsyncMongoengineObjectType

__version__ = "0.1.1"

__all__ = [
"__version__",
"MongoengineObjectType",
"AsyncMongoengineObjectType",
"MongoengineInputType",
"MongoengineInterfaceType",
"MongoengineConnectionField"
]
"MongoengineConnectionField",
"AsyncMongoengineConnectionField"
]
Loading
Loading