mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-23 23:20:47 +03:00
bit of refactoring
This commit is contained in:
parent
1538a2cc6e
commit
c4442b69b4
|
@ -1,9 +1,19 @@
|
||||||
import six
|
import six
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from ..utils.is_base_type import is_base_type
|
from ..utils.is_base_type import is_base_type
|
||||||
from .options import Options
|
from .options import Options
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_connection(cls):
|
||||||
|
from graphene.relay.connection import Connection
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
node = cls
|
||||||
|
|
||||||
|
return type('{}Connection'.format(cls.__name__), (Connection,), {'Meta': Meta})
|
||||||
|
|
||||||
|
|
||||||
class UnionMeta(type):
|
class UnionMeta(type):
|
||||||
|
|
||||||
def __new__(cls, name, bases, attrs):
|
def __new__(cls, name, bases, attrs):
|
||||||
|
@ -28,14 +38,8 @@ class UnionMeta(type):
|
||||||
|
|
||||||
get_connection = getattr(cls, 'get_connection', None)
|
get_connection = getattr(cls, 'get_connection', None)
|
||||||
if not get_connection:
|
if not get_connection:
|
||||||
from graphene.relay.connection import Connection
|
get_connection = partial(get_default_connection, cls)
|
||||||
|
|
||||||
class DefaultUnionConnection(Connection):
|
|
||||||
class Meta:
|
|
||||||
node = cls
|
|
||||||
|
|
||||||
cls.Connection = DefaultUnionConnection
|
|
||||||
else:
|
|
||||||
cls.Connection = get_connection()
|
cls.Connection = get_connection()
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
Loading…
Reference in New Issue
Block a user