pristas-peter / wp-graphql-gutenberg

Query gutenberg blocks with wp-graphql
https://wp-graphql-gutenberg.netlify.app
GNU General Public License v3.0
301 stars 62 forks source link

v3.0.9+ breaks blocksJSON response for some core Gutenberg blocks #122

Open clareoneill opened 3 years ago

clareoneill commented 3 years ago

Currently on WordPress 5.8, wp-graphql 1.6.4, and wp-graphql-gutenberg 0.3.11. Querying for any posts that contain the Post Title, Post Author, or Post Excerpt thow this type of error in the GraphQL response:

{
  "errors": [
    {
      "debugMessage": "Too few arguments to function gutenberg_render_block_core_post_title(), 2 passed in /app/web/wp-content/plugins/gutenberg/lib/compat.php on line 105 and exactly 3 expected",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "path": [
        "post",
        "blocksJSON"
      ],
      "trace": [
        {
          "file": "/app/web/wp-content/plugins/gutenberg/lib/compat.php",
          "line": 105,
          "function": "gutenberg_render_block_core_post_title(array(5), (empty string))"
        },
        {
          "file": "/app/web/wp-includes/class-wp-block-type.php",
          "line": 256,
          "function": "{closure}(array(5), (empty string))"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 200,
          "call": "WP_Block_Type::render(array(5))"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 188,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::render_dynamic_content()"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 25,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::__construct(array(5), 3763, array(85), 0, instance of WPGraphQLGutenberg\\Blocks\\Block)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 171,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::create_blocks(array(7), 3763, array(85), instance of WPGraphQLGutenberg\\Blocks\\Block)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 25,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::__construct(array(5), 3763, array(85), 0, instance of WPGraphQLGutenberg\\Blocks\\Block)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 171,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::create_blocks(array(1), 3763, array(85), instance of WPGraphQLGutenberg\\Blocks\\Block)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 25,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::__construct(array(5), 3763, array(85), 0, instance of WPGraphQLGutenberg\\Blocks\\Block)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 171,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::create_blocks(array(1), 3763, array(85), instance of WPGraphQLGutenberg\\Blocks\\Block)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Blocks/Block.php",
          "line": 25,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::__construct(array(5), 3763, array(85), 0, null)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql-gutenberg/src/Schema/Types/InterfaceType/BlockEditorContentNode.php",
          "line": 39,
          "call": "WPGraphQLGutenberg\\Blocks\\Block::create_blocks(array(3), 3763, array(85))"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/src/Utils/InstrumentSchema.php",
          "line": 151,
          "call": "WPGraphQLGutenberg\\Schema\\Types\\InterfaceType\\BlockEditorContentNode::WPGraphQLGutenberg\\Schema\\Types\\InterfaceType\\{closure}(instance of WPGraphQL\\Model\\Post, array(0), instance of WPGraphQL\\AppContext, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 623,
          "call": "WPGraphQL\\Utils\\InstrumentSchema::WPGraphQL\\Utils\\{closure}(instance of WPGraphQL\\Model\\Post, array(0), instance of WPGraphQL\\AppContext, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, instance of WPGraphQL\\Model\\Post, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: Post, instance of WPGraphQL\\Model\\Post, instance of ArrayObject(1), array(2))"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1145,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: Post, instance of WPGraphQL\\Model\\Post, array(1), instance of ArrayObject(3))"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1106,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: Post, instance of ArrayObject(1), array(1), instance of WPGraphQL\\Model\\Post)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 793,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: Post, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of WPGraphQL\\Model\\Post)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 651,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: Post, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of WPGraphQL\\Model\\Post)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php",
          "line": 148,
          "call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(instance of WPGraphQL\\Model\\Post)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php",
          "line": 53,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::GraphQL\\Executor\\Promise\\Adapter\\{closure}()"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php",
          "line": 149,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::runQueue()"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/Helper.php",
          "line": 214,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter::wait(instance of GraphQL\\Executor\\Promise\\Promise)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/StandardServer.php",
          "line": 136,
          "call": "GraphQL\\Server\\Helper::executeOperation(instance of GraphQL\\Server\\ServerConfig, instance of GraphQL\\Server\\OperationParams)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/src/Request.php",
          "line": 666,
          "call": "GraphQL\\Server\\StandardServer::executeRequest(instance of GraphQL\\Server\\OperationParams)"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/src/Router.php",
          "line": 468,
          "call": "WPGraphQL\\Request::execute_http()"
        },
        {
          "file": "/app/web/wp-content/plugins/wp-graphql/src/Router.php",
          "line": 270,
          "call": "WPGraphQL\\Router::process_http_request()"
        },
        {
          "file": "/app/web/wp-includes/class-wp-hook.php",
          "line": 303,
          "call": "WPGraphQL\\Router::resolve_http_request(instance of WP)"
        },
        {
          "file": "/app/web/wp-includes/class-wp-hook.php",
          "line": 327,
          "call": "WP_Hook::apply_filters(null, array(1))"
        },
        {
          "file": "/app/web/wp-includes/plugin.php",
          "line": 518,
          "call": "WP_Hook::do_action(array(1))"
        },
        {
          "file": "/app/web/wp-includes/class-wp.php",
          "line": 388,
          "function": "do_action_ref_array('parse_request', array(1))"
        },
        {
          "file": "/app/web/wp-includes/class-wp.php",
          "line": 750,
          "call": "WP::parse_request((empty string))"
        },
        {
          "file": "/app/web/wp-includes/functions.php",
          "line": 1291,
          "call": "WP::main((empty string))"
        },
        {
          "file": "/app/web/wp-blog-header.php",
          "line": 16,
          "function": "wp()"
        },
        {
          "file": "/app/web/index.php",
          "line": 17,
          "function": "require('/app/web/wp-blog-header.php')"
        }
      ]
    }
  ],
  "data": {
    "post": {
      "id": "cG9zdDozNzYz",
      "slug": "covid-housing-relief",
      "blocksJSON": null
    }
  },
  "extensions": {
    "debug": []
  }
}

I haven't tested every core block, but was able to pinpoint the issue to wp-graphql-gutenberg v0.3.9 or higher. When I roll back to v3.0.8 it works as expected and returns the blocksJSON response.

ojohnny commented 2 years ago

I can verify that the problem exists, and I have published a pull request (#140) to fix it.