From e701c33253031d0b15f98575f0861daf2586e625 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Mon, 27 Jul 2026 12:02:33 -0400 Subject: [PATCH] fix: drop textAlign from CoreHeading and CoreButton fragments Every blog post at /blog// 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. --- src/wp-blocks/core-button.jsx | 41 ++++++++++++++++++++++++++++++++++ src/wp-blocks/core-heading.jsx | 29 +++++++++++++++++++++++- src/wp-blocks/index.js | 2 ++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/wp-blocks/core-button.jsx diff --git a/src/wp-blocks/core-button.jsx b/src/wp-blocks/core-button.jsx new file mode 100644 index 00000000..be988096 --- /dev/null +++ b/src/wp-blocks/core-button.jsx @@ -0,0 +1,41 @@ +import { gql } from "@apollo/client"; +import { CoreBlocks } from "@faustwp/blocks"; + +const { CoreButton: FaustCoreButton } = CoreBlocks; + +export default function CoreButton(props) { + return ; +} + +CoreButton.displayName = { ...FaustCoreButton.displayName }; +CoreButton.config = { ...FaustCoreButton.config }; + +/** + * Faust's stock fragment requests `attributes.textAlign`, which no longer + * exists on `CoreButtonAttributes` in the CMS schema. GraphQL rejects the + * whole document at validation time, so every blog post 500s. Neither the + * component nor `getStyles` reads `textAlign` (alignment arrives via + * `cssClassName`), so dropping the field changes nothing visually. + */ +CoreButton.fragments = { + key: "CoreButtonBlockFragment", + entry: gql` + fragment CoreButtonBlockFragment on CoreButton { + attributes { + anchor + gradient + text + textColor + style + fontSize + fontFamily + linkTarget + rel + url + backgroundColor + cssClassName + linkClassName + } + } + `, +}; diff --git a/src/wp-blocks/core-heading.jsx b/src/wp-blocks/core-heading.jsx index 8f51ab21..4b23d360 100644 --- a/src/wp-blocks/core-heading.jsx +++ b/src/wp-blocks/core-heading.jsx @@ -1,3 +1,4 @@ +import { gql } from "@apollo/client"; import { CoreBlocks } from "@faustwp/blocks"; import slugify from "@sindresorhus/slugify"; @@ -16,4 +17,30 @@ export default function CoreHeading(props) { CoreHeading.displayName = { ...FaustCoreHeading.displayName }; CoreHeading.config = { ...FaustCoreHeading.config }; -CoreHeading.fragments = { ...FaustCoreHeading.fragments }; +/** + * Faust's stock fragment requests `attributes.textAlign`, which no longer + * exists on `CoreHeadingAttributes` in the CMS schema. GraphQL rejects the + * whole document at validation time, so every blog post 500s. Neither the + * component nor `getStyles` reads `textAlign` (alignment arrives via + * `cssClassName`), so dropping the field changes nothing visually. + */ +CoreHeading.fragments = { + key: "CoreHeadingBlockFragment", + entry: gql` + fragment CoreHeadingBlockFragment on CoreHeading { + attributes { + align + anchor + backgroundColor + content + fontFamily + fontSize + gradient + level + style + textColor + cssClassName + } + } + `, +}; diff --git a/src/wp-blocks/index.js b/src/wp-blocks/index.js index 5e81ed3c..44458e08 100644 --- a/src/wp-blocks/index.js +++ b/src/wp-blocks/index.js @@ -1,9 +1,11 @@ import { CoreBlocks } from "@faustwp/blocks"; +import CoreButton from "./core-button"; import CoreEmbed from "./core-embed"; import CoreHeading from "./core-heading"; export default { ...CoreBlocks, CoreHeading, + CoreButton, CoreEmbed, };