fix: drop textAlign from CoreHeading and CoreButton fragments - #383
Conversation
Every blog post at /blog/<slug>/ returns a 500. The cause is GraphQL schema drift, not a rendering error. @faustwp/blocks ships CoreHeadingBlockFragment and CoreButtonBlockFragment that request `attributes.textAlign`. That field no longer exists on CoreHeadingAttributes (the schema now exposes `align`) or on CoreButtonAttributes (removed outright) in the cms.faustjs.org schema: Cannot query field "textAlign" on type "CoreButtonAttributes". Cannot query field "textAlign" on type "CoreHeadingAttributes". GraphQL rejects the entire document at validation time, so the query returns no data at all and getNextStaticProps throws before the notFound guard in getStaticProps can run. That is why a nonexistent slug also returns 500 instead of 404, and why /blog/ itself is unaffected: the index template queries editorBlocks without these fragments. Override both fragments locally with the textAlign field removed. Neither the Faust component nor getStyles reads textAlign; alignment reaches the DOM through cssClassName, so rendering is unchanged. CoreQuote also requests textAlign, but CoreQuoteAttributes still exposes it, so that fragment is left alone. Upgrading the package does not help: 6.1.9 ships the same fragments.
|
Check out the recent updates to your Headless Platform preview environment:
Learn more about preview environments in our documentation. |
There was a problem hiding this comment.
Pull request overview
This PR addresses blog post pages (/blog/<slug>/) returning 500s by removing GraphQL fragment selections (attributes.textAlign) that no longer exist in the CMS schema, preventing query validation failures that abort getStaticProps before the notFound path can run.
Changes:
- Override the
CoreHeadingblock fragment to dropattributes.textAlignand requestattributes.aligninstead. - Add a local override for the
CoreButtonblock fragment to dropattributes.textAlign. - Register the new
CoreButtonoverride in the local block registry so it replaces Faust’s stock block definition.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/wp-blocks/index.js | Registers the local CoreButton override alongside existing overrides so it supersedes @faustwp/blocks defaults. |
| src/wp-blocks/core-heading.jsx | Replaces Faust’s heading fragment with a local fragment that omits textAlign to match the CMS schema. |
| src/wp-blocks/core-button.jsx | Introduces a local CoreButton override with a fragment that omits textAlign to avoid GraphQL validation failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Check out the recent updates to your Headless Platform preview environment:
Learn more about preview environments in our documentation. |
|
Check out the recent updates to your Headless Platform preview environment:
Learn more about preview environments in our documentation. |
Every blog post 500s. Nonexistent slugs 500 as well instead of 404ing, while
/blog/is fine.WordPress 6.8 moved
textAlignoncore/buttonfrom a block attribute to a block support, so WPGraphQL Content Blocks stopped exposing it. It is gone fromCoreButtonAttributesand fromCoreHeadingAttributes, which now usesalign. Faust's stock heading and button fragments still request it, so GraphQL rejects the whole document at validation andgetNextStaticPropsthrows before thenotFoundguard ingetStaticPropscan run. The blog index survives because its template querieseditorBlockswithout those fragments.This overrides both fragments locally without
textAlign. Nothing renders differently: alignment reaches the DOM throughcssClassName, and neither the Faust component norgetStylesreadstextAlign.CoreQuotestill requests it and is left alone, sinceCoreQuoteAttributesstill exposes it. Bumping@faustwp/blocksdoes not help, the current release ships the same fragments.Upstream: wpengine/faustjs#2383. Same break as wpengine/faustjs#1932, where
alignwas dropped fromCoreQuoteAttributes.Checked the composed query against the live schema. It fails validation on
main, validates on this branch, and returns a null post for a nonexistent slug, which 404s correctly.Worth a separate look:
getStaticProps500s on any GraphQL error rather than degrading, so the next schema change will take the blog down the same way.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): claude-opus-5
Used for: Root cause investigation, drafting, and implementation