mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-23 15:10:48 +03:00
Improved connection type of checking
This commit is contained in:
parent
42b93b5546
commit
3fa65aa343
|
@ -95,6 +95,10 @@ class Connection(six.with_metaclass(ConnectionMeta, ObjectType)):
|
||||||
def Field(cls, *args, **kwargs): # noqa: N802
|
def Field(cls, *args, **kwargs): # noqa: N802
|
||||||
return ConnectionField(cls, *args, **kwargs)
|
return ConnectionField(cls, *args, **kwargs)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_type_of(cls, root, context, info):
|
||||||
|
return isinstance(root, cls)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def connection_resolver(cls, resolved, args, context, info):
|
def connection_resolver(cls, resolved, args, context, info):
|
||||||
assert isinstance(resolved, Iterable), (
|
assert isinstance(resolved, Iterable), (
|
||||||
|
@ -132,7 +136,7 @@ class ConnectionField(Field):
|
||||||
def connection_resolver(cls, resolver, connection_type, root, args, context, info):
|
def connection_resolver(cls, resolver, connection_type, root, args, context, info):
|
||||||
resolved = resolver(root, args, context, info)
|
resolved = resolver(root, args, context, info)
|
||||||
|
|
||||||
if isinstance(resolved, connection_type):
|
if connection_type.is_type_of(resolved, context, info):
|
||||||
return resolved
|
return resolved
|
||||||
|
|
||||||
on_resolve = partial(connection_type.connection_resolver, args=args, context=context, info=info)
|
on_resolve = partial(connection_type.connection_resolver, args=args, context=context, info=info)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user