Daniel Barbakadze
Daniel Barbakadze

Reputation: 211

wp-graphql - can't query acf globalOptions

I create a new field in Custom Fields and give it a location, like this:

enter image description here

After that I activate the Show In GraphQL button and set acf name:

enter image description here

Now, I'm trying to make a query for acf globalOptions in wp-graphql and it gives me an error. Moreover, I can't find globalOptions either in suggestions or in the schema.

GraphiQL-IDE: playground

Docs:

schema

How could I fix this problem?

Thanks in advance.

Upvotes: 1

Views: 1640

Answers (1)

Daniel Barbakadze
Daniel Barbakadze

Reputation: 211

The problem was in a file functions.php:

it was like:

acf_add_options_page(array(
    'page_title' => __('Global Options'),
    'menu_title' => __('Global Options'),
    'autoload' => true,
));

But it should be like:

acf_add_options_page(array(
    'page_title' => __('Global Options'),
    'menu_title' => __('Global Options'),
    'autoload' => true,
    'show_in_graphql' => true
));

I was missing the 'show_in_graphql' => true key:value pair.

Upvotes: 3

Related Questions