Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
425 stars 58 forks source link

How to enable show_in_graphql for option page ? #155

Closed gol4nsky closed 1 year ago

gol4nsky commented 1 year ago

It is possibile to enable by default "show_in_graphql" when new option page is creating ?

Log1x commented 1 year ago

Not for option pages in specific (unless you edit the stub), but for all field groups you can do:

'fieldGroup' => ['show_in_graphql' => true],

inside of config/acf.php

gol4nsky commented 1 year ago

Hi, thank you for answer, but it doesn't seems like it working, I can't see field group in graphql query

Log1x commented 1 year ago

Are you using ACF 6.0+?

It looks like it should be 'show_in_rest' => 1

gol4nsky commented 1 year ago

Yes, i'm using 6.1.3, after adding 'show_in_rest' => 1, still the same, not available in graphql query

Log1x commented 1 year ago

Does it work if you add it to the field group directly in your options class?

Log1x commented 1 year ago

Tried this myself. I'm not really sure the route/path the options page is supposed to have when registered with ACF? Is it even possible?

Log1x commented 1 year ago

https://support.advancedcustomfields.com/forums/topic/options-page-in-rest-api-2/#post-160315

gol4nsky commented 1 year ago

I'm using WPGraphQL for Advanced Custom Fields, https://github.com/wp-graphql/wp-graphql-acf#options-pages, but i guess i cant do it with acf composer so never mind, i'll do it with normal way, thank you

Log1x commented 1 year ago

I see.

I could probably add something like a $settings property to the Options class that merges with the options page registration so you could do something like public $settings = ['show_in_graphql' => true].

How does that sound?

gol4nsky commented 1 year ago

I will be perfect :)

Log1x commented 1 year ago

Try out composer require log1x/acf-composer:dev-master

Add:

    /**
     * The additional option page settings.
     *
     * @var array
     */
    public $settings = ['show_in_graphql' => 1];

to your Options class. Let me know if it works.

gol4nsky commented 1 year ago

It works prefect, thank you very much :)