pristas-peter / wp-graphql-gutenberg-acf

Expose acf blocks through graphql
MIT License
62 stars 29 forks source link

undefined method - block_type_fields() #30

Open leogilmour opened 3 years ago

leogilmour commented 3 years ago

Currently have this error (appearing in custom fields plugin)

Fatal error: Uncaught Error: Call to undefined method WPGraphQLGutenbergACF\WPGraphQLGutenbergACF::block_type_fields() in ../app/plugins/wp-graphql-gutenberg-acf/plugin.php:154 Stack trace: #0 ../wp/wp-includes/class-wp-hook.php(292): WPGraphQLGutenbergACF{closure}(Array, Array, Object(WPGraphQL\Registry\TypeRegistry))

1 ../wp/wp-includes/plugin.php(212): WP_Hook->apply_filters(Array, Array)

2 ../app/plugins/wp-graphql-gutenberg/src/Schema/Types/BlockTypes.php(224): apply_filters('graphql_gutenbe...', Array, Array, Object(WPGraphQL\Registry\TypeRegistry))

3 ../app/plugins/wp-graphql-gutenberg/src/Schema/Types/BlockTypes.php(256): WPGraphQLGutenberg\Schema\Types\BlockTypes::register_block_type(Array, Object(WPGraphQL\Registry\TypeRegistry))

4 ../wp/wp-includes/class-wp-hook.php(292): WPGraphQLGutenberg\Schema\Types\BlockTypes->WPGraphQLGuten in /Users/leogilmour/code/aethel-wp/app/plugins/wp-graphql-gutenberg-acf/plugin.php on line 154

And "There has been a critical error on this website.

<a href=\"https://wordpress.org/support/article/faq-troubleshooting/\">Learn more about troubleshooting WordPress.

", "status": 500 On the GraphQL endpoint

LucasZapico commented 3 years ago

I have this error too... have you had any luck resolving it? This is killing my deadline.. 😓

leogilmour commented 3 years ago

Unfortunately... I've resolved to use the blocks JSON field ... 😫 nightmare

LucasZapico commented 3 years ago

Wow, I looked at that option and it looked rough. Ok, I might just tackle that too and hope one of the repo maintainers resolves the issue at some point. I spent most of Saturday trying to figure out what was going on here

add_filter(
    'graphql_gutenberg_block_type_fields',
    function ( $fields, $block_type, $type_registry ) {

        return WPGraphQLGutenbergACF::instance()->block_type_fields( $fields, $block_type, $type_registry );
    },
    10,
    3
);

It's not like I'm not beating my head against a wall already. What is one more wall?

Here is a link to my slack channel if you're interested in tackling integration with some help

Good Luck 😁

leogilmour commented 3 years ago

Well I think I am discovering that the images within the ACF block JSON are not responding to the ACF options to return as URLs / Arrays... Which is a new nightmare. Have you come across this if you did use the JSON?

LucasZapico commented 3 years ago

Oh that's lovely, I am still wrestling nested components as it seems everything is the same level in the attributes.data. I just looked at the image field for the block I'm working on and low and behold it's just a number. Oof this is crazy, it seems like WordPress as a headless CMS for Gatsby is still WIP.... 😩😩 I hope you're in a better spot than I am. l just tweeted the repo owner to see if there is a timeline on resolution.

LucasZapico commented 3 years ago

Hey, @leonoragilmour I rolled back my versions and thus far everything seems to be working. Not an ideal fix but thought you might want to know.

composer.json

....
"require" : {
  ...
  "wp-graphql/wp-graphql-acf": "0.3.5",
  "pristas-peter/wp-graphql-gutenberg": "0.3.8",
  "wpackagist-plugin/wp-gatsby": "1.0",
  "wpackagist-plugin/wp-graphql": "1.3",
  "pristas-peter/wp-graphql-gutenberg-acf": "0.3.0"
....
}
....

I'll let you know if I get everything working. Images, nested fields etc.

leogilmour commented 3 years ago

@LucasZapico Thanks :) So I tried installing the plugin versions you had, and my wp is completely broken. Won't start up, and I have this error:

Fatal error: require(): Failed opening required '/Users/leogilmour/code/repo/app/plugins/wp-gatsby/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php' (include_path='.:/usr/local/Cellar/php@7.4/7.4.20/share/php@7.4/pear') in /Users/leogilmour/code/repo/app/plugins/wp-gatsby/vendor/composer/autoload_real.php on line 66

Have tried with PHP 7.3 too.

Wondered if it could be that we have different WP versions? If you could share the other plugin version you have installed, maybe that would help? Would love to have this working!

LucasZapico commented 3 years ago

That's odd, my wordpress version is "roots/wordpress": "5.*",. I have it running in multiple instances of Wordpress to ensure it "actually worked"

I found that if you uninstall wp-graphql-acf,wp-graphql-gutenberg , wp-graphql-acf and then install wp-graphql-gutenberg-acf it will install the versioned dependencies for you.

Pardon the late reply.