Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blocksJSON error with WordPress 6.5 #204

Open
colis opened this issue Apr 3, 2024 · 5 comments
Open

blocksJSON error with WordPress 6.5 #204

colis opened this issue Apr 3, 2024 · 5 comments

Comments

@colis
Copy link
Contributor

colis commented Apr 3, 2024

There seems to be a validation issue with the blocksJSON field and WordPress 6.5.

This is what I'm seeing

[
  {
    "message": "Internal server error",
    "locations": [
      {
        "line": 113,
        "column": 3
      }
    ],
    "path": [
      "lot",
      "blocksJSON"
    ],
    "extensions": {
      "category": "internal"
    },
    "debugMessage": "'type' keyword contains unknown value: rich-text"
  }
]

Due to this error the blocksJSON field returns null. Reverting to WP 6.4 solves the problem.

This is the check that fails:

if (!$this->helper->typeExists($schema->type)) {
throw new SchemaKeywordException(
$schema,
'type',
$schema->type,
"'type' keyword contains unknown value: " . $schema->type
);
}

const JSON_TYPES = ["null", "boolean", "number", "integer", "string", "array", "object"];

Steps to reproduce:

  1. Update WordPress to version 6.5
  2. Go to the WP GraphQL Gutenberg plugin settings page and click the “Update” button to update the block registry
  3. Go to the GraphiQL IDE and execute a query that contains the blocksJSON field
@colis
Copy link
Contributor Author

colis commented Apr 3, 2024

It looks like the only way to pass the schema validation is to add the rich-text type to the ValidatorHelper JSON_TYPES array, e.g.

<?php

namespace WPGraphQLGutenberg\Schema;

use Opis\JsonSchema\ValidatorHelper;

class CustomValidatorHelper extends ValidatorHelper
{
    const JSON_TYPES = ["null", "boolean", "number", "integer", "string", "array", "object", "rich-text"];
}

and then use the new CustomValidatorHelper class when instantiating the Validator

$validator = new Validator( new CustomValidatorHelper() );

instead of

$validator = new Validator();

@noonstudio
Copy link

Related to the 6.5 Wordpress Update – to this have you noticed that the 'content' attribute on is now no longer valid on the Core Block attributes. If so have you managed to overcome this?

 ... on CoreParagraphBlock {
        attributes {
          ... on CoreParagraphBlockAttributes {
            align
            anchor
            className
            content
          }
        }
      }

@colis
Copy link
Contributor Author

colis commented Apr 3, 2024

@noonstudio you also need to change a couple other files

needs to be

case 'rich-text':
case 'string':
    $type = 'String';
    break;

needs to be

case 'html':
case 'rich-text':

@fantaz-st
Copy link

Related to the 6.5 Wordpress Update – to this have you noticed that the 'content' attribute on is now no longer valid on the Core Block attributes. If so have you managed to overcome this?

 ... on CoreParagraphBlock {
        attributes {
          ... on CoreParagraphBlockAttributes {
            align
            anchor
            className
            content
          }
        }
      }

yes, just realized that.

@Messa1
Copy link

Messa1 commented Oct 7, 2024

I got the same on my local env. Good i found this issuse.
@colis did you already make a pr? Is this repro till maintainted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants