mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 09:57:53 +03:00 
			
		
		
		
	Change types.py
This commit is contained in:
		
							parent
							
								
									96110b05bb
								
							
						
					
					
						commit
						54fae91632
					
				| 
						 | 
					@ -3,11 +3,11 @@ from collections import OrderedDict
 | 
				
			||||||
from functools import partial
 | 
					from functools import partial
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import six
 | 
					import six
 | 
				
			||||||
import graphene
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from django.db.models import Model
 | 
					from django.db.models import Model
 | 
				
			||||||
from django.utils.functional import SimpleLazyObject
 | 
					from django.utils.functional import SimpleLazyObject
 | 
				
			||||||
from graphene import Field, NonNull
 | 
					
 | 
				
			||||||
 | 
					import graphene
 | 
				
			||||||
 | 
					from graphene import Field
 | 
				
			||||||
from graphene.relay import Connection, Node
 | 
					from graphene.relay import Connection, Node
 | 
				
			||||||
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
 | 
					from graphene.types.objecttype import ObjectType, ObjectTypeOptions
 | 
				
			||||||
from graphene.types.utils import yank_fields_from_attrs
 | 
					from graphene.types.utils import yank_fields_from_attrs
 | 
				
			||||||
| 
						 | 
					@ -25,11 +25,13 @@ from .utils import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if six.PY3:
 | 
					if six.PY3:
 | 
				
			||||||
    from typing import Type
 | 
					    from typing import Type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ALL_FIELDS = "__all__"
 | 
					ALL_FIELDS = "__all__"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def construct_fields(
 | 
					def construct_fields(
 | 
				
			||||||
        model, registry, only_fields, exclude_fields, convert_choices_to_enum
 | 
					    model, registry, only_fields, exclude_fields, convert_choices_to_enum
 | 
				
			||||||
):
 | 
					):
 | 
				
			||||||
    _model_fields = get_model_fields(model)
 | 
					    _model_fields = get_model_fields(model)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -147,23 +149,6 @@ class DjangoObjectTypeOptions(ObjectTypeOptions):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DjangoObjectType(ObjectType):
 | 
					class DjangoObjectType(ObjectType):
 | 
				
			||||||
    """
 | 
					 | 
				
			||||||
    DjangoObjectType inheritance to handle field authorization
 | 
					 | 
				
			||||||
    Accepts field's permissions description as:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    class Meta:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        field_to_permission = {
 | 
					 | 
				
			||||||
            'restricted_field': ('permission1', 'permission2')
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        permission_to_field = {
 | 
					 | 
				
			||||||
            'permission': ('restricted_field_1', 'restricted_field_2')
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    At least one of the permissions must be accomplished in order to resolve the field.
 | 
					 | 
				
			||||||
    """
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @classmethod
 | 
					    @classmethod
 | 
				
			||||||
    def __init_subclass_with_meta__(
 | 
					    def __init_subclass_with_meta__(
 | 
				
			||||||
            cls,
 | 
					            cls,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user