File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ Object types
20
20
.. autoclass :: graphene.Mutation
21
21
:members:
22
22
23
+ .. _fields-mounted-types :
24
+
23
25
Fields (Mounted Types)
24
26
----------------------
25
27
Original file line number Diff line number Diff line change @@ -158,6 +158,22 @@ You can then execute the following query:
158
158
}
159
159
}
160
160
161
+ * Note:* There are several arguments to a field that are " reserved" by Graphene
162
+ (see :ref:`fields- mounted- types` ).
163
+ You can still define an argument that clashes with one of these fields by using
164
+ the `` args`` parameter like so:
165
+
166
+ .. code:: python
167
+
168
+ from graphene import ObjectType, Field, String
169
+
170
+ class Query(ObjectType):
171
+ answer = String(args = {' description' : String()})
172
+
173
+ def resolve_answer(parent, info, description):
174
+ return description
175
+
176
+
161
177
Convenience Features of Graphene Resolvers
162
178
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163
179
Original file line number Diff line number Diff line change @@ -40,11 +40,12 @@ class Person(ObjectType):
40
40
last_name = graphene.Field(String, description='Surname') # explicitly mounted as Field
41
41
42
42
args:
43
- type (class for a graphene.UnmountedType): must be a class (not an instance) of an
43
+ type (class for a graphene.UnmountedType): Must be a class (not an instance) of an
44
44
unmounted graphene type (ex. scalar or object) which is used for the type of this
45
45
field in the GraphQL schema.
46
- args (optional, Dict[str, graphene.Argument]): arguments that can be input to the field.
47
- Prefer to use **extra_args.
46
+ args (optional, Dict[str, graphene.Argument]): Arguments that can be input to the field.
47
+ Prefer to use ``**extra_args``, unless you use an argument name that clashes with one
48
+ of the Field arguments presented here (see :ref:`example<ResolverParamGraphQLArguments>`).
48
49
resolver (optional, Callable): A function to get the value for a Field from the parent
49
50
value object. If not set, the default resolver method for the schema is used.
50
51
source (optional, str): attribute name to resolve for this field from the parent value
You can’t perform that action at this time.
0 commit comments