How do I deprecate fields of input types?

Have more questions? Submit a request

The most recent official release of the GraphQL spec (Oct 2021) does not support applying the built-in @deprecated directive to fields of an input type. However, there are workarounds for deprecating an input field.

If you have a Federation 2 supergraph, you can apply the @deprecated directive to input fields, even though it isn't currently supported in the spec:

input MyInput {
  firstField: String
  two: String @deprecated(reason: "don't need it!")
}

Alternatively, you can create a new query/mutation and deprecate the old one:

type Query {
  oldField(input: OldInput): Int @deprecated(reason: "Uses old input type, use newField instead")
  newField(input: NewInput): Int
}

Articles in this section

Was this article helpful?
0 out of 0 found this helpful
Share

Comments

0 comments

Article is closed for comments.