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

Fix compatibility with wp-graphql-gutenberg-acf #114

Open jonsherrard opened 3 years ago

jonsherrard commented 3 years ago

Simply casting the$attributes array to an object before running it though Schema validation fails with ACF Pro's field groups. ACF outputs another nested array. Using JSON decode makes sure that nested arrays are converted to objects as well.

There is also an issue with the HTML loader failing if there's no innerHTML defined in the block. HTML-less blocks are very useful for WordPress as a headless CMS with WPGraphQL.

I've added a check for empty HTML and added an empty span with a data-attr warning about the lack of innerHTML.