StoutLogic / acf-builder

An Advanced Custom Field Configuration Builder
GNU General Public License v2.0
794 stars 62 forks source link

Support for WPGraphQL? #129

Closed intelligence closed 3 years ago

intelligence commented 3 years ago

Anyone managed to get acf-builder to play nice with WPGraphQL / WPGraphQL ACF? https://github.com/wp-graphql/wp-graphql-acf

Would be nice to be able to fields created with acf-builder to show up in the schema.

newloong commented 3 years ago

+1

Log1x commented 3 years ago

try setting ['show_in_graphql' => true] on your fields

intelligence commented 3 years ago

Yup, that works, thanks @Log1x!

yano1978 commented 1 year ago

@Log1x Hi sorry to bother on an already closed "issue", how should be exactly added in my fields ['show_in_graphql' => true] ? Thanks in advance!

stevep commented 1 year ago

@yano1978 Add it to the group config

You can do it when creating the FieldsBuilder

$banner = new StoutLogic\AcfBuilder\FieldsBuilder('banner', [
    'show_in_graphql' => true,
]);

or you can do it after

$banner = new StoutLogic\AcfBuilder\FieldsBuilder('banner');

...

$banner->setGroupConfig('show_in_graphql',true)

You can also set graphql_field_name if needed

yano1978 commented 1 year ago

Hi @stevep and thanks for the quick reply and help. I have tried both options as you suggested but it doesn't seem to work?

image image

image Am I missing something? Thank you!

stevep commented 1 year ago

To confirm: you have the WPGraphQL for Advanced Custom Fields plugin installed?

yano1978 commented 1 year ago

Indeed these are plugins installed:

yano1978 commented 1 year ago

Hi @stevep again, just to let you know that, after some more diggings into wp_graphl documentation, I have finally found out how to add it here https://www.wpgraphql.com/docs/custom-post-types#filtering-an-existing-post-type Basically, for an already existing acf custom type, it's sufficient to add it with addfilter function into functions.php like in the example's link.

image

I hope it might help someone else 😉