Improved documentation

This commit is contained in:
Syrus Akbary 2016-06-05 19:29:24 -07:00
parent ad607eb122
commit 19dff03784
2 changed files with 18 additions and 3 deletions

View File

@ -26,8 +26,8 @@ class NodeMeta(InterfaceTypeMeta):
@property @property
def Field(cls): def Field(cls):
# We put as a property for reset the field counter each time is setted up, so # We put as a property for reset the field counter each time is called
# it will be order correctly wherever is mounted # so it will be order correctly wherever is mounted
field = copy.copy(cls._Field) field = copy.copy(cls._Field)
field.reset_counter() field.reset_counter()
return field return field

View File

@ -4,10 +4,25 @@ from ..utils.orderedtype import OrderedType
class TypeProxy(OrderedType): class TypeProxy(OrderedType):
'''
This class acts a proxy for a Graphene Type, so it can be mounted
as Field, InputField or Argument.
Instead of doing
>>> class MyObjectType(ObjectType):
>>> my_field = Field(String(), description='Description here')
You can actually do
>>> class MyObjectType(ObjectType):
>>> my_field = String(description='Description here')
So is simpler to use.
'''
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.args = args self.args = args
self.kwargs = kwargs self.kwargs = kwargs
OrderedType.__init__(self) super(TypeProxy, self).__init__()
def get_type(self): def get_type(self):
return self._meta.graphql_type return self._meta.graphql_type