AxeWP / wp-graphql-rank-math

Add GraphQL support for RankMath SEO
GNU General Public License v3.0
50 stars 7 forks source link

Blog page seo returns null #111

Closed amoyanoakqa closed 1 week ago

amoyanoakqa commented 2 weeks ago

Description

All pages are working ok on the graphql query, except blog page returns null

Steps to reproduce

(obviously the page has rank math seo snippet data)

query blog($idType: PageIdType!, $id: ID!) { page(idType: $idType, id: $id) { title seo { title description canonicalUrl robots openGraph { alternateLocales description articleMeta { publishedTime modifiedTime } image { height secureUrl type url width } locale siteName title type updatedTime url twitterMeta { card creator description image site title } } } } }

// Vars { "idType": "DATABASE_ID", "id": "5" }

Returns

{ "data": { "page": { "title": "Blog", "seo": null } }, "extensions": { "debug": [ { "type": "DEBUG_LOGS_INACTIVE", "message": "GraphQL Debug logging is not active. To see debug logs, GRAPHQL_DEBUG must be enabled." } ] } }

Additional context

No response

Plugin Version

0.3.2

WordPress Version

6.6.1

WPGraphQL Version

1.22

RankMath SEO Version

6.6.1

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

Please confirm that you have disabled ALL plugins except for RankMath SEO, WPGraphQL, and WPGraphQL for Rank Math

justlevine commented 2 weeks ago

Thanks for reporting this @amoyanoakqa

Few follow-ups:

  1. Can you confirm with the latest version of WPGraphQL (v1.28.1 as of time of writing)?
  2. Please confirm that you have disabled ALL plugins except for RankMath SEO, WPGraphQL, and WPGraphQL for Rank Math. You skipped this. Does the issue persist with only these 3 plugins activated?
  3. How are your Home Page / Posts Page configured?
  4. If you turn on GraphQL Debugging and run the query, what does the response look like?

Basically, WPGraphQL doesn't have an Archive type, so the way the "Posts page" (I'm assuming what you mean by Blog page) works is both finicky and has been subject to several fixes since WPGraphQL v1.22.x.

I'm pretty sure that by querying for page (instead of contentType, or even better nodeByUri ), you're casting the response to act as a Page (with a seo: RankMathPageObjectSeo shape), when it should be a ContentType with the seo: RankMathPostTypeSeo) which is why it's returning null here (as a Page it indeed should not have accessible SEO ), but without the above information I can't know for sure.

amoyano commented 2 weeks ago

nodebyuri worked!!

Ty

justlevine commented 1 week ago

Hey @amoyano ,

113 adds a debug message to the GraphQL response explaining why the Page.seo returns null for the Posts page. Hopefully will save others the headache you experienced 🤞