wpengine / wp-graphql-content-blocks

Plugin that extends WPGraphQL to support querying (Gutenberg) Blocks as data

Home Page:https://faustjs.org/docs/gutenberg/wp-graphql-content-blocks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing fields in GraphQL query

MKlblangenois opened this issue · comments

I recently upgrade WordPress core and plugins to the latest version, and now when I try to generate schemas, it gave me error about core blocks that missing some field (like text for CoreButton or caption for CoreImage)
image

When I inspect the schema.graphql from the last release, these fields exist but when I try to query them on GraphiQL IDE, they doesn't exist.
SCR-20240403-irnt

I've tried with default theme and other plugin disabled but the issue persist.

  • Wordpress version: 6.5
  • WPGraphQL: 1.22.1
  • WPGraphQL Content Blocks: 3.1.2

After several tests, it seems that the problem comes from the update to WordPress 6.5, I tested up to 6.4.3 without problem

@MKlblangenois it looks like WordPress has indeed changed up their block fields with some breaking changes. At least GraphQL was able to detect any conflicts here before it's too late.

Hovever its quite tricky to roll out a new release of the @faust/blocks package since we will have to do a major upgrade release version to make this work. Clients could still be using old versions, and if we update the fragments now, it will break their code.

I could suggest to override the block fragments directly before you export them until we provide a new release.

Here is an example:
https://github.com/wpengine/faustjs/blob/canary/examples/next/block-support/wp-blocks/index.js

import { CoreBlocks } from '@faustwp/blocks';
import BlockB from './block-b/Component.js';
import { gql } from '@apollo/client';

CoreBlocks.CoreParagraph.fragments.entry = gql`

` // Update Fragment query here before exporting component.

export default {
  CoreParagraph: CoreBlocks.CoreParagraph,
  ...

I could also suggest to open ticket in https://github.com/wpengine/faustjs so that we are aware of this change.

This is because the source for those fields has changed to rich-text.

Adding rich-text as a case in the following switch should solve the problem

Hey @colis How on earth did they add this type without even documenting it? Strange. I will provide a PR today.

Hey @colis latest version fixes this issue.