diff --git a/graphene_sqlalchemy/converter.py b/graphene_sqlalchemy/converter.py index 05690697..9b110cfb 100644 --- a/graphene_sqlalchemy/converter.py +++ b/graphene_sqlalchemy/converter.py @@ -8,7 +8,7 @@ from graphene.relay import is_node from graphene.types.json import JSONString -from .fields import SQLAlchemyConnectionField +from .fields import createConnectionField try: from sqlalchemy_utils import ChoiceType, JSONType, ScalarListType @@ -36,7 +36,7 @@ def dynamic_type(): elif (direction == interfaces.ONETOMANY or direction == interfaces.MANYTOMANY): if is_node(_type): - return SQLAlchemyConnectionField(_type) + return createConnectionField(_type) return Field(List(_type)) return Dynamic(dynamic_type) diff --git a/graphene_sqlalchemy/fields.py b/graphene_sqlalchemy/fields.py index de1d301f..31c73a5f 100644 --- a/graphene_sqlalchemy/fields.py +++ b/graphene_sqlalchemy/fields.py @@ -41,3 +41,15 @@ def connection_resolver(cls, resolver, connection, model, root, args, context, i def get_resolver(self, parent_resolver): return partial(self.connection_resolver, parent_resolver, self.type, self.model) + + +__connectionFactory = SQLAlchemyConnectionField + + +def createConnectionField(_type): + return __connectionFactory(_type) + + +def registerConnectionFieldFactory(factoryMethod): + global __connectionFactory + __connectionFactory = factoryMethod