Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use correct post type when querying for ContentNodeSeo on revisions. #44

Merged
merged 6 commits into from
May 10, 2023

Conversation

idflood
Copy link
Contributor

@idflood idflood commented Apr 25, 2023

Implement fix for get_object_type() when object is a revision.

What

The function get_object_type returned null when using asPreview parameter.

Why

When using asPreview, the content type is revision and doesn't match the allowed types.

How

This pull request check if $this->data->post_type is a revision, and if this is the case it returns the parent post type.

Testing Instructions

You can try a query like this while being connected.


{
  contentNode(id: "2011", idType: DATABASE_ID, asPreview: true) {
    ... on Page {
      title

      seo {
          description
      }
    }
  }
}

The graphql error happen after adding asPreview parameter.

Checklist:

  • My code is tested to the best of my abilities.
  • My code follows the WordPress Coding Standards.
  • My code has proper inline documentation.
  • I have added unit tests to verify the code works as intended.
  • The changes in this PR have been noted in CHANGELOG.md

@justlevine
Copy link
Member

Thanks for this @idflood ! I've confirmed both the issue and this fix locally, and plan to add the missing unit test and get it merged over the weekend.

PS: this PR qualifies for my WPGraphQL Spring Cleaning campaign, where I'm donating dev hours to WPGraphQL projects for every issue/PR opened between now and April 31st. If you're interested, let me know via the link where you want the time donated to.

@justlevine justlevine force-pushed the fix-post-type-revision-preview branch from fa1276f to d050704 Compare May 10, 2023 18:04
@justlevine justlevine changed the title Update ContentNodeSeo.php fix: Use correct post type when querying for ContentNodeSeo on revisions. May 10, 2023
@justlevine justlevine merged commit c8b683e into AxeWP:develop May 10, 2023
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants