mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-10-30 15:37:52 +03:00 
			
		
		
		
	Simplify code
This commit is contained in:
		
							parent
							
								
									cbcaac66d0
								
							
						
					
					
						commit
						56000394c4
					
				|  | @ -1,8 +1,4 @@ | ||||||
| from collections import defaultdict, Mapping, OrderedDict | from collections import Mapping, OrderedDict | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def nested_dict(): |  | ||||||
|     return defaultdict(nested_dict) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def deflate(node, index=None, path=None): | def deflate(node, index=None, path=None): | ||||||
|  | @ -13,24 +9,15 @@ def deflate(node, index=None, path=None): | ||||||
| 
 | 
 | ||||||
|     if node and 'id' in node and '__typename' in node: |     if node and 'id' in node and '__typename' in node: | ||||||
|         route = ','.join(path) |         route = ','.join(path) | ||||||
|  |         cache_key = ':'.join([route, str(node['__typename']), str(node['id'])]) | ||||||
| 
 | 
 | ||||||
|         if ( |         if index.get(cache_key) is True: | ||||||
|             route in index and |  | ||||||
|             node['__typename'] in index[route] and |  | ||||||
|             index[route][node['__typename']].get(node['id']) |  | ||||||
|         ): |  | ||||||
|             return { |             return { | ||||||
|                 '__typename': node['__typename'], |                 '__typename': node['__typename'], | ||||||
|                 'id': node['id'], |                 'id': node['id'], | ||||||
|             } |             } | ||||||
|         else: |         else: | ||||||
|             if route not in index: |             index[cache_key] = True | ||||||
|                 index[route] = {} |  | ||||||
| 
 |  | ||||||
|             if node['__typename'] not in index[route]: |  | ||||||
|                 index[route][node['__typename']] = {} |  | ||||||
| 
 |  | ||||||
|             index[route][node['__typename']][node['id']] = True |  | ||||||
| 
 | 
 | ||||||
|     field_names = node.keys() |     field_names = node.keys() | ||||||
|     result = OrderedDict() |     result = OrderedDict() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user