mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Improved documentation in UnmountedTypes
This commit is contained in:
parent
0a80119f5e
commit
47d7adf7b0
|
@ -58,5 +58,10 @@ class Enum(six.with_metaclass(EnumTypeMeta, UnmountedType)):
|
||||||
kind of type, often integers.
|
kind of type, often integers.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def get_type(self):
|
@classmethod
|
||||||
return type(self)
|
def get_type(cls):
|
||||||
|
'''
|
||||||
|
This function is called when the unmounted type (Enum instance)
|
||||||
|
is mounted (as a Field, InputField or Argument)
|
||||||
|
'''
|
||||||
|
return cls
|
||||||
|
|
|
@ -50,4 +50,8 @@ class InputObjectType(six.with_metaclass(InputObjectTypeMeta, UnmountedType)):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_type(cls):
|
def get_type(cls):
|
||||||
|
'''
|
||||||
|
This function is called when the unmounted type (InputObjectType instance)
|
||||||
|
is mounted (as a Field, InputField or Argument)
|
||||||
|
'''
|
||||||
return cls
|
return cls
|
||||||
|
|
|
@ -43,6 +43,10 @@ class Scalar(six.with_metaclass(ScalarTypeMeta, UnmountedType)):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_type(cls):
|
def get_type(cls):
|
||||||
|
'''
|
||||||
|
This function is called when the unmounted type (Scalar instance)
|
||||||
|
is mounted (as a Field, InputField or Argument)
|
||||||
|
'''
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
# As per the GraphQL Spec, Integers are only treated as valid when a valid
|
# As per the GraphQL Spec, Integers are only treated as valid when a valid
|
||||||
|
|
|
@ -12,6 +12,10 @@ class Structure(UnmountedType):
|
||||||
self.of_type = of_type
|
self.of_type = of_type
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
|
'''
|
||||||
|
This function is called when the unmounted type (List or NonNull instance)
|
||||||
|
is mounted (as a Field, InputField or Argument)
|
||||||
|
'''
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ class UnmountedType(OrderedType):
|
||||||
|
|
||||||
Instead of writing
|
Instead of writing
|
||||||
>>> class MyObjectType(ObjectType):
|
>>> class MyObjectType(ObjectType):
|
||||||
>>> my_field = Field(String(), description='Description here')
|
>>> my_field = Field(String, description='Description here')
|
||||||
|
|
||||||
It let you write
|
It let you write
|
||||||
>>> class MyObjectType(ObjectType):
|
>>> class MyObjectType(ObjectType):
|
||||||
|
@ -21,6 +21,10 @@ class UnmountedType(OrderedType):
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
|
'''
|
||||||
|
This function is called when the UnmountedType instance
|
||||||
|
is mounted (as a Field, InputField or Argument)
|
||||||
|
'''
|
||||||
raise NotImplementedError("get_type not implemented in {}".format(self))
|
raise NotImplementedError("get_type not implemented in {}".format(self))
|
||||||
|
|
||||||
def Field(self): # noqa: N802
|
def Field(self): # noqa: N802
|
||||||
|
|
Loading…
Reference in New Issue
Block a user