Transformers are used by the source plugins to parse content. They are automatically used as long as they are installed and found in package.json.
transformer.mimeTypes()A transformer must have a static mimeTypes method which returns an array of mime types the transformer should be able to parse.
transformer.parse(source)A transformer must also implement a parse method that will be executed be source plugins to parse content. The method must return a node.
transformer.extendNodeType()Transformers can also extend nodes in the GraphQL schema with additional fields by implementing a extendNodeType method. The fields will only be added to nodes it has transformed.
class Transformer {
  static mimeTypes () {
    return ['application/json']
  }
  parse (source) {
    const { title, ...fields } = JSON.parse(source)
    return {
      title,
      fields
    }
  }
  extendNodeType ({ graphql }) {
    return {
      // custom GraphQL fields for transformed node
    }
  }
}
module.exports = Transformer