graphene icon indicating copy to clipboard operation
graphene copied to clipboard

Can I use deprecation_reason in InputObjectType?

Open shmilyhurt opened this issue 4 years ago • 2 comments

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

shmilyhurt avatar Aug 11 '20 03:08 shmilyhurt

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

KingDarBoja avatar Aug 15 '20 21:08 KingDarBoja

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.

akikoskinen avatar Mar 08 '21 11:03 akikoskinen