@@ -31,18 +31,22 @@ class Argument(MountedType):
31
31
type (class for a graphene.UnmountedType): must be a class (not an instance) of an
32
32
unmounted graphene type (ex. scalar or object) which is used for the type of this
33
33
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
35
35
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
39
39
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).
40
43
"""
41
44
42
45
def __init__ (
43
46
self ,
44
47
type_ ,
45
48
default_value = Undefined ,
49
+ deprecation_reason = None ,
46
50
description = None ,
47
51
name = None ,
48
52
required = False ,
@@ -51,12 +55,16 @@ def __init__(
51
55
super (Argument , self ).__init__ (_creation_counter = _creation_counter )
52
56
53
57
if required :
58
+ assert (
59
+ deprecation_reason is None
60
+ ), f"Argument { name } is required, cannot deprecate it."
54
61
type_ = NonNull (type_ )
55
62
56
63
self .name = name
57
64
self ._type = type_
58
65
self .default_value = default_value
59
66
self .description = description
67
+ self .deprecation_reason = deprecation_reason
60
68
61
69
@property
62
70
def type (self ):
@@ -68,6 +76,7 @@ def __eq__(self, other):
68
76
and self .type == other .type
69
77
and self .default_value == other .default_value
70
78
and self .description == other .description
79
+ and self .deprecation_reason == other .deprecation_reason
71
80
)
72
81
73
82
0 commit comments