graphene
graphene copied to clipboard
Can I use deprecation_reason in InputObjectType?
Hi, I want to mark some fields as "deprecation_reason" in my filter fields. example: TestQuery{ filter:TestFilter } TestFilter{ id: IntFilter, name: StringFilter } StringFilter = type("String", graphene.InputobjectType, {key:value}) How can I mark "name" is "deprecation_reason"? thanks
Not sure about what you trying to do with StringFilter
definition but you can do something like the doc examples:
from graphene import InputObjectType, String, InputField
class Person(InputObjectType):
# implicitly mounted as Input Field
first_name = String(required=True)
# explicitly mounted as Input Field
last_name = InputField(String, description="Surname", deprecation_reason="This is deprecated") # <-- `deprecation_reason`
Applies for any type that can be mounted as InputField
(Object Type, Scalar Type, Enum). See https://docs.graphene-python.org/en/latest/api/#fields-mounted-types
Not exactly sure what is wanted here, but I doubt it's possible within the limits of the current (June 2018) GraphQL specification. The deprecation feature in GraphQL (the specification) is very limited. The @deprecated
directive is only applicable to field definitions and enum values. Notably, input objects and input field definitions (which I suppose were probably asked for in this issue) are not supported by the @deprecated
directive.