pristas-peter / wp-graphql-gutenberg

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

Querying reusableBlock returns null #156

Open andyjamesn opened 2 years ago

andyjamesn commented 2 years ago

I have a reusable block and I am trying to return it's dynamicContent

{
  reusableBlock(id: "10061756", idType: DATABASE_ID) {
    blocks {
      dynamicContent
      saveContent
    }
  }
}

But it is just returning

{
  "data": {
    "reusableBlock": null
  },
  "extensions": {
    "debug": []
  }
}

I have tried all kinds of combinations and it always returns null

If I query a page where the block is, it works fine.

Am I missing something?

vstrelianyi commented 1 year ago

Hi there! I have the same issue - resulting empty array Did you arrive at any solution?

vstrelianyi commented 1 year ago

I have found out that query for RB need authentication with Bearer Token included issue is resolved

th1988 commented 1 year ago

You can allow to query reusableBlocks without authentication if you want with this:

<?php

add_filter('graphql_data_is_private', function($is_private, $model_name, $data, $visibility, $owner, $current_user) {
    if ('PostObject' === $model_name && 'wp_block' === $data->post_type) {
        return false;
    }

    return $is_private;
}, 10, 6);

?>