mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-11-04 09:57:41 +03:00 
			
		
		
		
	Merge pull request #641 from presencelearning/issue-610-connection-name
Allow ObjectType to set Connection name
This commit is contained in:
		
						commit
						a0fc843513
					
				| 
						 | 
					@ -73,7 +73,7 @@ class Connection(ObjectType):
 | 
				
			||||||
        edge = type(edge_name, edge_bases, {})
 | 
					        edge = type(edge_name, edge_bases, {})
 | 
				
			||||||
        cls.Edge = edge
 | 
					        cls.Edge = edge
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        _meta.name = name
 | 
					        options['name'] = name
 | 
				
			||||||
        _meta.node = node
 | 
					        _meta.node = node
 | 
				
			||||||
        _meta.fields = OrderedDict([
 | 
					        _meta.fields = OrderedDict([
 | 
				
			||||||
            ('page_info', Field(PageInfo, name='pageInfo', required=True)),
 | 
					            ('page_info', Field(PageInfo, name='pageInfo', required=True)),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,6 +52,21 @@ def test_connection_inherit_abstracttype():
 | 
				
			||||||
    assert list(fields.keys()) == ['page_info', 'edges', 'extra']
 | 
					    assert list(fields.keys()) == ['page_info', 'edges', 'extra']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_connection_name():
 | 
				
			||||||
 | 
					    custom_name = "MyObjectCustomNameConnection"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class BaseConnection(object):
 | 
				
			||||||
 | 
					        extra = String()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class MyObjectConnection(BaseConnection, Connection):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        class Meta:
 | 
				
			||||||
 | 
					            node = MyObject
 | 
				
			||||||
 | 
					            name = custom_name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert MyObjectConnection._meta.name == custom_name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_edge():
 | 
					def test_edge():
 | 
				
			||||||
    class MyObjectConnection(Connection):
 | 
					    class MyObjectConnection(Connection):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -125,6 +140,7 @@ def test_connectionfield_node_deprecated():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert "ConnectionField's now need a explicit ConnectionType for Nodes." in str(exc_info.value)
 | 
					    assert "ConnectionField's now need a explicit ConnectionType for Nodes." in str(exc_info.value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_connectionfield_custom_args():
 | 
					def test_connectionfield_custom_args():
 | 
				
			||||||
    class MyObjectConnection(Connection):
 | 
					    class MyObjectConnection(Connection):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user