Add field for unencoded content

The following adds a field to the NodeWithContentEditor interface to get the unencoded content for a post:

add_action( 'graphql_register_types', function() {
	register_graphql_field( 'NodeWithContentEditor', 'unencodedContent', [
		'type' => 'String',
		'resolve' => function( $post ) {
			$content = get_post( $post->databaseId )->post_content;
			return ! empty( $content ) ?  apply_filters( 'the_content', $content ) : null;
		}
	]);
});

You can query now query for this field:

{
  contentNode(id: 952, idType: DATABASE_ID) {
    id
    ... on NodeWithTitle {
      title
    }
    ... on NodeWithContentEditor {
      content
      unencodedContent
    }
  }
}
Unencoded Content query in GraphiQL

Related Links