AxeWP / wp-graphql-rank-math

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

Enabled schema in the RM dashboard ruins FE builds #114

Open floretsky opened 4 days ago

floretsky commented 4 days ago

Description

Hello!

I encountered a problem with the schema (Structured Data) setting enabled in the RM dashboard:

Image

I have been chatting with the RM developers about it and they have suggested to implement a fix which didn't fix it for me.

The code that is ruining the builds is located under \plugins\seo-by-rank-math\includes\modules\schema\class-snippet-shortcode.php It's not a part of the wp-graphql-rank-math plugin, but seems like this part of code is running multiple times because wp-graphql-rank-math creates an instance of RM which runs this code part multiple times and throws Internal Server Error

Steps to reproduce

My website build is based on the stack which includes faustjs, sage theme and bedrock WPGraphQL Query I'm running is

fragment SEOInformationFragment on NodeWithRankMathSeo {
      seo { 
        fullHead
        breadcrumbTitle
        breadcrumbs {
          text
          url
          isHidden
        }
        canonicalUrl
        description
        focusKeywords
        jsonLd {
          raw
        }
        robots
        title
        openGraph {
          articleMeta {
            section
          }
          description
          locale
          siteName
          title
          type
          url
          slackEnhancedData {
            data
            label
          }
          twitterMeta {
            card
            description
            title
          }
        }
      }
    }

Let me know if I can provide any more additional helpful information. Thank you!

Additional context

No response

Plugin Version

0.3.2

WordPress Version

6.6.2

WPGraphQL Version

1.29.0

RankMath SEO Version

1.0.232

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 4 days ago

Hey @floretsky and thanks for the thorough bug report!

Yeah sadly seems the support team's response isn't relevant in this case.

seems like this part of code is running multiple times because wp-graphql-rank-math creates an instance of RM

Can you clarify what you mean by this? I'm currently afk, but I to my memory, this is what we reset/reinstantiate

floretsky commented 3 days ago

Hi @justlevine ! Thanks for your reply!

Ah, my mistake! During my last troubleshooting session, I thought I found out that the RankMath\Schema\Snippet_Shortcode constructor was being executed twice, which caused my builds to fail. But that doesn't seem to be the issue here. I have the Headless CMS Support setting enabled in RankMath. Seems like with the "Schema" setting enabled, it attempts to register the rank-math/rich-snippet block for every GraphQL node.