wp-graphql-content-blocks icon indicating copy to clipboard operation
wp-graphql-content-blocks copied to clipboard

Reusable block isn't resolved inside columns

Open MKlblangenois opened this issue 1 year ago • 3 comments

When I try to make a query to resolve innerBlocks of Core/Block (reusable block), I only got renderedHtml, but it doesn't resolve innerBlocks or attributes, but when I use it inside root of Gutenberg, GraphQL resolve innerBlocks block to display them as root too.

SCR-20240205-jtol

Step to reproduce:

  1. Create a block (on my case : heading + paragraph and group them)
  2. Save it has reusable
  3. Add a columns block
  4. Insert reusable block inside one column

This is what it looks like used on the same page: SCR-20240205-jwnv

GraphQL result
{
  "data": {
    "testPage": {
      "editorBlocks": [
        {
          "name": "core/group",
          "innerBlocks": [
            {
              "name": "core/heading",
              "innerBlocks": []
            },
            {
              "name": "core/paragraph",
              "innerBlocks": []
            },
            {
              "name": "core/buttons",
              "innerBlocks": [
                {
                  "name": "core/button",
                  "innerBlocks": []
                },
                {
                  "name": "core/button",
                  "innerBlocks": []
                },
                {
                  "name": "core/button",
                  "innerBlocks": []
                },
                {
                  "name": "core/button",
                  "innerBlocks": []
                }
              ]
            }
          ]
        },
        {
          "name": "core/columns",
          "innerBlocks": [
            {
              "name": "core/column",
              "innerBlocks": [
                {
                  "name": "core/paragraph",
                  "innerBlocks": []
                }
              ]
            },
            {
              "name": "core/column",
              "innerBlocks": [
                {
                  "name": "core/block",
                  "innerBlocks": []
                }
              ]
            }
          ]
        },
      ]
    }
  },
}

Version:

  • wp-graphql-content-blocks: 2.0.0
  • Faust.js: 1.2.1
  • WPGraphQL: 1.20.0

MKlblangenois avatar Feb 05 '24 09:02 MKlblangenois

Hey @MKlblangenois I think reusable blocks only resolve when using the editorBlocks field instead of the editorBlocks(flat: false) which you are using.

See: https://github.com/wpengine/wp-graphql-content-blocks/blob/main/includes/Data/ContentBlocksResolver.php#L57-L68

theodesp avatar Feb 06 '24 12:02 theodesp

@MKlblangenois were you able to fix your issues?

theodesp avatar Mar 12 '24 15:03 theodesp

Hey @MKlblangenois I think reusable blocks only resolve when using the editorBlocks field instead of the editorBlocks(flat: false) which you are using.

See: https://github.com/wpengine/wp-graphql-content-blocks/blob/main/includes/Data/ContentBlocksResolver.php#L57-L68

@theodesp is that a bug, known limitation, or intended behavior?

If it's one of the latter two, can this be documented somewhere? (If it is already, I can't find it)

justlevine avatar Mar 12 '24 15:03 justlevine

Hey @MKlblangenois Thanks for the report. I will provide a fix for this.

theodesp avatar Jun 27 '24 10:06 theodesp