mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
Fixed issues
This commit is contained in:
parent
5a949ce209
commit
11a5ee189e
|
@ -25,18 +25,18 @@ class ConnectionField(Field):
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.connection_type = connection_type
|
self.connection_type = connection_type
|
||||||
self.edge_type = edge_type
|
self.edge_type = edge_type
|
||||||
|
|
||||||
@with_context
|
@with_context
|
||||||
def resolver(self, instance, args, context, info):
|
def resolver(self, instance, args, context, info):
|
||||||
schema = info.schema.graphene_schema
|
schema = info.schema.graphene_schema
|
||||||
connection_type = self.get_type(schema)
|
connection_type = self.get_type(schema)
|
||||||
|
|
||||||
resolver = super(ConnectionField, self).resolver
|
resolver = super(ConnectionField, self).resolver
|
||||||
if has_context(resolver):
|
if has_context(resolver):
|
||||||
resolved = super(ConnectionField, self).resolver(instance, args, context, info)
|
resolved = super(ConnectionField, self).resolver(instance, args, context, info)
|
||||||
else:
|
else:
|
||||||
resolved = super(ConnectionField, self).resolver(instance, args, info)
|
resolved = super(ConnectionField, self).resolver(instance, args, info)
|
||||||
|
|
||||||
if isinstance(resolved, connection_type):
|
if isinstance(resolved, connection_type):
|
||||||
return resolved
|
return resolved
|
||||||
return self.from_list(connection_type, resolved, args, context, info)
|
return self.from_list(connection_type, resolved, args, context, info)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Query(graphene.ObjectType):
|
||||||
special_node = relay.NodeField(SpecialNode)
|
special_node = relay.NodeField(SpecialNode)
|
||||||
all_my_nodes = relay.ConnectionField(
|
all_my_nodes = relay.ConnectionField(
|
||||||
MyNode, connection_type=MyConnection, customArg=graphene.String())
|
MyNode, connection_type=MyConnection, customArg=graphene.String())
|
||||||
|
|
||||||
context_nodes = relay.ConnectionField(
|
context_nodes = relay.ConnectionField(
|
||||||
MyNode, connection_type=MyConnection, customArg=graphene.String())
|
MyNode, connection_type=MyConnection, customArg=graphene.String())
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class Query(graphene.ObjectType):
|
||||||
custom_arg = args.get('customArg')
|
custom_arg = args.get('customArg')
|
||||||
assert custom_arg == "1"
|
assert custom_arg == "1"
|
||||||
return [MyNode(name='my')]
|
return [MyNode(name='my')]
|
||||||
|
|
||||||
@with_context
|
@with_context
|
||||||
def resolve_context_nodes(self, args, context, info):
|
def resolve_context_nodes(self, args, context, info):
|
||||||
custom_arg = args.get('customArg')
|
custom_arg = args.get('customArg')
|
||||||
|
@ -71,7 +71,7 @@ def test_nodefield_query():
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
expected = {
|
expected = {
|
||||||
'allMyNodes': {
|
'contextNodes': {
|
||||||
'edges': [{
|
'edges': [{
|
||||||
'node': {
|
'node': {
|
||||||
'name': 'my'
|
'name': 'my'
|
||||||
|
@ -87,6 +87,7 @@ def test_nodefield_query():
|
||||||
assert not result.errors
|
assert not result.errors
|
||||||
assert result.data == expected
|
assert result.data == expected
|
||||||
|
|
||||||
|
|
||||||
def test_connectionfield_context_query():
|
def test_connectionfield_context_query():
|
||||||
query = '''
|
query = '''
|
||||||
query RebelsShipsQuery {
|
query RebelsShipsQuery {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user