Skip to content

Add filter/action hooks to override or modify existing SEO field resolvers (e.g. seo.opengraphImage) #192

Description

@tuncadev

Feature request: Add hooks to override or modify existing SEO field resolvers

Hi
First of all, thank you for the plugin - it’s a critical plugin for headless WordPress setups using Yoast.

I’d like to propose adding extension hooks (filters/actions) that allow developers to modify or override resolved SEO values (for example seo.opengraphImage) without redefining or duplicating schema fields.


Problem

Once a field like the following is registered:

seo {
  opengraphImage {
    sourceUrl
  }
}

there is currently no supported way to:

  • modify the resolved value
  • override specific fallback logic
  • prevent certain sources (e.g. first content image)
  • inject custom resolution rules

Because GraphQL schemas are immutable, developers are forced to:

  • introduce parallel fields (seoClean, seoCustom, etc.)
  • or completely bypass the plugin’s resolver logic

This leads to:

  • schema duplication
  • frontend complexity
  • diverging SEO contracts

Proposed solution

Introduce filters or actions around resolver output, for example:

apply_filters(
    'wpgraphql_seo_opengraph_image',
    $resolved_value,
    $indexable,
    $post_id,
    $context
);

Or a more generic hook:

apply_filters(
    'wpgraphql_seo_resolve_field',
    $value,
    $field_name,
    $node,
    $context
);

This would allow developers to:

  • modify the returned image URL
  • block content-based images
  • enforce featured or global images
  • inject custom enterprise logic
  • keep the GraphQL schema intact

Why this matters

  • Keeps the GraphQL schema stable
  • Avoids field duplication
  • Enables advanced SEO control
  • Aligns with WordPress’s filter-based extensibility
  • Better supports headless / enterprise use cases

Example use case

Prevent Yoast from ever using the “first content image” fallback, while still allowing:

  1. Explicit Yoast social image
  2. Featured image
  3. Global default image

Currently this cannot be done cleanly without duplicating fields or reimplementing resolver logic.


Happy to help with discussion, implementation ideas, or a PR if this aligns with the project’s direction

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions