diff --git a/docs/api/index.rst b/docs/api/index.rst index 47b8b84f..0da427e4 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -20,6 +20,8 @@ Object types .. autoclass:: graphene.Mutation :members: +.. _fields-mounted-types: + Fields (Mounted Types) ---------------------- diff --git a/docs/types/objecttypes.rst b/docs/types/objecttypes.rst index 721090ac..e37c3030 100644 --- a/docs/types/objecttypes.rst +++ b/docs/types/objecttypes.rst @@ -159,16 +159,16 @@ You can then execute the following query: } *Note:* There are several arguments to a field that are "reserved" by Graphene -(you can see the full list here: https://docs.graphene-python.org/en/latest/api/#fields-mounted-types). +(see :ref:`fields-mounted-types`). You can still define an argument that clashes with one of these fields by using -the ``args`` paramter like so: +the ``args`` parameter like so: .. code:: python from graphene import ObjectType, Field, String class Query(ObjectType): - answer = graphene.Int(args={'description': graphene.Int()}) + answer = String(args={'description': String()}) def resolve_answer(parent, info, description): return description diff --git a/graphene/types/field.py b/graphene/types/field.py index 2af73781..a956952c 100644 --- a/graphene/types/field.py +++ b/graphene/types/field.py @@ -40,11 +40,12 @@ class Field(MountedType): last_name = graphene.Field(String, description='Surname') # explicitly mounted as Field args: - type (class for a graphene.UnmountedType): must be a class (not an instance) of an + type (class for a graphene.UnmountedType): Must be a class (not an instance) of an unmounted graphene type (ex. scalar or object) which is used for the type of this field in the GraphQL schema. - args (optional, Dict[str, graphene.Argument]): arguments that can be input to the field. - Prefer to use **extra_args. + args (optional, Dict[str, graphene.Argument]): Arguments that can be input to the field. + Prefer to use ``**extra_args``, unless you use an argument name that clashes with one + of the Field arguments presented here (see :ref:`example`). resolver (optional, Callable): A function to get the value for a Field from the parent value object. If not set, the default resolver method for the schema is used. source (optional, str): attribute name to resolve for this field from the parent value