How to remove a field or collection from graphql schema?

I would like to know how to deprecate a field or a collection in my graphql schema.

For example a collection like this:

type Person {
  name: String
  age: Int
}

and I would like to remove the age field

type Person {
  name: String
}

Considering that I would already have documents with the age field populated.

My guess would be to update all documents to have age as null and then upload a new schema (merge) without the age field in the collection. Is that the way to do it?

Or is it that once there is a field in a schema we are stuck with that field until we do a complete override? (which would replace the schema and I understand it will delete the documents)

Just update the schema.

Fields that exist in documents, but are not specified in the schema, continue to exist, but are “unreachable” by the GraphQL API. The GraphQL API is only aware of declared fields.

If you want to make sure that the document structure matches the schema, you’d need to run one or more FQL queries to eliminate the fields in all covered documents. Override mode accomplishes that, but might delete other field values or documents that you wanted to keep.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.