Skip to content

Modify how meta is handled in revisions now that the block editor revises meta #3260

Description

@jasonbahl

What problem does this address?

For a long time WordPress did not revise meta, so we came up with a bit of a "shim" to have fields that call for meta to resolve from the parent (the published post) so that null values were not returned, but rather the published post's values were returned.

Now that meta revisions are supported by WordPress core, it would be good to revisit our shim (see: https://github.com/wp-graphql/wp-graphql/blob/develop/src/Utils/Preview.php#L7-L57).

What is your proposed solution?

Currently we can use this filter to tell WPGraphQL to use the revision meta instead of the parent (published post) meta.

add_filter( 'graphql_resolve_revision_meta_from_parent', function( $default, $object_id, $meta_key, $meta_value ) {
	if ( 'footnotes' === $meta_key ) {
		return false;
	}
}, 10, 4);

I would like to use the meta registry to automate this, so that any meta field that has opted-in to revisions would automatically work without users having to implement a filter manually like this.

What alternatives have you considered?

Allowing users to continue explicitly opt-in/out using the graphql_resolve_revision_meta_from_parent filter.

Additional Context

related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: model layerRelating to the Model Layereffort: medLess than a weekimpact: medMinor performance improvements, fix broad user base issuesobject type: postRelating to the Post Object Typesscope: apiIssues related to access functions, actions, and filtersstatus: actionableReady for work to begintype: enhancementImprovements to existing functionality

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions