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 1 commit
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
Prev Previous commit
Next Next commit
Bug Fix: Argument Parser
  • Loading branch information
arunsureshkumar committed Apr 12, 2023
commit 2b2813d6bfce4f0bbefd89b7a03829a2ef7ee864
14 changes: 11 additions & 3 deletions graphene_mongo/fields_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from pymongo.errors import OperationFailure
from asgiref.sync import sync_to_async
from concurrent.futures import ThreadPoolExecutor

from .registry import get_global_async_registry
from . import MongoengineConnectionField
from .utils import get_query_fields, find_skip_and_limit, \
connection_from_iterables
connection_from_iterables, ExecutorEnum
import pymongo

PYMONGO_VERSION = tuple(pymongo.version_tuple[:2])
Expand All @@ -29,6 +29,10 @@ class AsyncMongoengineConnectionField(MongoengineConnectionField):
def __init__(self, type, *args, **kwargs):
super(AsyncMongoengineConnectionField, self).__init__(type, *args, **kwargs)

@property
def executor(self):
return ExecutorEnum.ASYNC

@property
def type(self):
from .types_async import AsyncMongoengineObjectType
Expand All @@ -44,7 +48,11 @@ def type(self):

@property
def fields(self):
return super().fields
return super(AsyncMongoengineConnectionField, self).fields

@property
def registry(self):
return getattr(self.node_type._meta, "registry", get_global_async_registry())

async def default_resolver(self, _root, info, required_fields=None, resolved=None, **args):
if required_fields is None:
Expand Down
21 changes: 21 additions & 0 deletions graphene_mongo/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,36 @@ def get_inputs_registry():
return inputs_registry


def get_inputs_async_registry():
global async_inputs_registry
if not async_inputs_registry:
async_inputs_registry = Registry()
return async_inputs_registry


def get_global_registry():
global registry
if not registry:
registry = Registry()
return registry


def get_global_async_registry():
global async_registry
if not async_registry:
async_registry = Registry()
return async_registry


def reset_global_registry():
global registry
global inputs_registry
registry = None
inputs_registry = None


def reset_global_async_registry():
global async_registry
global async_inputs_registry
async_registry = None
async_inputs_registry = None
13 changes: 8 additions & 5 deletions graphene_mongo/types_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from graphene import InputObjectType
from graphene.relay import Connection, Node
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
from graphene.types.interface import Interface, InterfaceOptions
from graphene.types.utils import yank_fields_from_attrs
from graphene.utils.str_converters import to_snake_case
from graphene_mongo import AsyncMongoengineConnectionField

from .registry import Registry, get_global_registry, \
get_inputs_registry
from .registry import Registry, get_global_async_registry, \
get_inputs_async_registry
from .types import construct_fields, construct_self_referenced_fields
from .utils import is_valid_mongoengine_model, get_query_fields, ExecutorEnum

Expand Down Expand Up @@ -55,9 +56,9 @@ def __init_subclass_with_meta__(
if not registry:
# input objects shall be registred in a separated registry
if issubclass(cls, InputObjectType):
registry = get_inputs_registry()
registry = get_inputs_async_registry()
else:
registry = get_global_registry()
registry = get_global_async_registry()

assert isinstance(registry, Registry), (
"The attribute registry in {}.Meta needs to be an instance of "
Expand Down Expand Up @@ -192,5 +193,7 @@ def resolve_id(self, info):

AsyncMongoengineObjectType, AsyncMongoengineObjectTypeOptions = create_graphene_generic_class_async(ObjectType,
ObjectTypeOptions)
AsyncMongoengineInterfaceType, MongoengineInterfaceTypeOptions = create_graphene_generic_class_async(Interface,
InterfaceOptions)

AsyncGrapheneMongoengineObjectTypes = (AsyncMongoengineObjectType,)
AsyncGrapheneMongoengineObjectTypes = (AsyncMongoengineObjectType, AsyncMongoengineInterfaceType)