mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-10-30 23:47:55 +03:00 
			
		
		
		
	* Propagate name, deprecation_reason arguments of relay.NodeField to Field * Allow custom description in Node.Field and move ID description to ID argument * Add test for Node.Field with custom name * Add tests for description, deprecation_reason arguments of NodeField * Pass all kwargs from NodeField to Field Co-authored-by: Theodore Diamantidis <diamaltho@gmail.com>
This commit is contained in:
		
							parent
							
								
									3d0e460be1
								
							
						
					
					
						commit
						afa44e8a5f
					
				|  | @ -48,7 +48,7 @@ class GlobalID(Field): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class NodeField(Field): | class NodeField(Field): | ||||||
|     def __init__(self, node, type=False, deprecation_reason=None, name=None, **kwargs): |     def __init__(self, node, type=False, **kwargs): | ||||||
|         assert issubclass(node, Node), "NodeField can only operate in Nodes" |         assert issubclass(node, Node), "NodeField can only operate in Nodes" | ||||||
|         self.node_type = node |         self.node_type = node | ||||||
|         self.field_type = type |         self.field_type = type | ||||||
|  | @ -57,8 +57,8 @@ class NodeField(Field): | ||||||
|             # If we don's specify a type, the field type will be the node |             # If we don's specify a type, the field type will be the node | ||||||
|             # interface |             # interface | ||||||
|             type or node, |             type or node, | ||||||
|             description="The ID of the object", |             id=ID(required=True, description="The ID of the object"), | ||||||
|             id=ID(required=True), |             **kwargs | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|     def get_resolver(self, parent_resolver): |     def get_resolver(self, parent_resolver): | ||||||
|  |  | ||||||
|  | @ -110,6 +110,17 @@ def test_node_field_custom(): | ||||||
|     assert node_field.node_type == Node |     assert node_field.node_type == Node | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def test_node_field_args(): | ||||||
|  |     field_args = { | ||||||
|  |         "name": "my_custom_name", | ||||||
|  |         "description": "my_custom_description", | ||||||
|  |         "deprecation_reason": "my_custom_deprecation_reason", | ||||||
|  |     } | ||||||
|  |     node_field = Node.Field(**field_args) | ||||||
|  |     for field_arg, value in field_args.items(): | ||||||
|  |         assert getattr(node_field, field_arg) == value | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def test_node_field_only_type(): | def test_node_field_only_type(): | ||||||
|     executed = schema.execute( |     executed = schema.execute( | ||||||
|         '{ onlyNode(id:"%s") { __typename, name } } ' % Node.to_global_id("MyNode", 1) |         '{ onlyNode(id:"%s") { __typename, name } } ' % Node.to_global_id("MyNode", 1) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user