mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 09:57:53 +03:00 
			
		
		
		
	added a test and made the type property better
This commit is contained in:
		
							parent
							
								
									dc6e8f110a
								
							
						
					
					
						commit
						207f4ebb41
					
				| 
						 | 
				
			
			@ -1,3 +1,5 @@
 | 
			
		|||
import inspect
 | 
			
		||||
 | 
			
		||||
from collections import OrderedDict
 | 
			
		||||
from functools import partial
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +23,7 @@ class DjangoFilterConnectionField(DjangoConnectionField):
 | 
			
		|||
 | 
			
		||||
    @property
 | 
			
		||||
    def node_type(self):
 | 
			
		||||
        if callable(self._type):
 | 
			
		||||
        if inspect.isfunction(self._type) or inspect.ismethod(self._type):
 | 
			
		||||
            return self._type()
 | 
			
		||||
        return self._type
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -350,3 +350,20 @@ def test_filter_filterset_related_results():
 | 
			
		|||
    assert not result.errors
 | 
			
		||||
    # We should only get two reporters
 | 
			
		||||
    assert len(result.data['allReporters']['edges']) == 2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_recursive_filter_connection():
 | 
			
		||||
    class ReporterFilterNode(DjangoObjectType):
 | 
			
		||||
        child_reporters = DjangoFilterConnectionField(lambda: ReporterFilterNode)
 | 
			
		||||
 | 
			
		||||
        def resolve_child_reporters(self, args, context, info):
 | 
			
		||||
            return []
 | 
			
		||||
 | 
			
		||||
        class Meta:
 | 
			
		||||
            model = Reporter
 | 
			
		||||
            interfaces = (Node, )
 | 
			
		||||
 | 
			
		||||
    class Query(ObjectType):
 | 
			
		||||
        all_reporters = DjangoFilterConnectionField(ReporterFilterNode)
 | 
			
		||||
 | 
			
		||||
    assert ReporterFilterNode._meta.fields['child_reporters'].node_type == ReporterFilterNode
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user