@@ -31,18 +31,22 @@ class Argument(MountedType):
3131 type (class for a graphene.UnmountedType): must be a class (not an instance) of an
3232 unmounted graphene type (ex. scalar or object) which is used for the type of this
3333 argument in the GraphQL schema.
34- required (bool): indicates this argument as not null in the graphql schema. Same behavior
34+ required (optional, bool): indicates this argument as not null in the graphql schema. Same behavior
3535 as graphene.NonNull. Default False.
36- name (str): the name of the GraphQL argument. Defaults to parameter name.
37- description (str): the description of the GraphQL argument in the schema.
38- default_value (Any): The value to be provided if the user does not set this argument in
36+ name (optional, str): the name of the GraphQL argument. Defaults to parameter name.
37+ description (optional, str): the description of the GraphQL argument in the schema.
38+ default_value (optional, Any): The value to be provided if the user does not set this argument in
3939 the operation.
40+ deprecation_reason (optional, str): Setting this value indicates that the argument is
41+ depreciated and may provide instruction or reason on how for clients to proceed. Cannot be
42+ set if the argument is required (see spec).
4043 """
4144
4245 def __init__ (
4346 self ,
4447 type_ ,
4548 default_value = Undefined ,
49+ deprecation_reason = None ,
4650 description = None ,
4751 name = None ,
4852 required = False ,
@@ -51,12 +55,16 @@ def __init__(
5155 super (Argument , self ).__init__ (_creation_counter = _creation_counter )
5256
5357 if required :
58+ assert (
59+ deprecation_reason is None
60+ ), f"Argument { name } is required, cannot deprecate it."
5461 type_ = NonNull (type_ )
5562
5663 self .name = name
5764 self ._type = type_
5865 self .default_value = default_value
5966 self .description = description
67+ self .deprecation_reason = deprecation_reason
6068
6169 @property
6270 def type (self ):
@@ -68,6 +76,7 @@ def __eq__(self, other):
6876 and self .type == other .type
6977 and self .default_value == other .default_value
7078 and self .description == other .description
79+ and self .deprecation_reason == other .deprecation_reason
7180 )
7281
7382
0 commit comments