Skip to content

Options Fields Return Null #128

@TheHatcheryLabs

Description

@TheHatcheryLabs

Description

ACF options page is set to 'show_in_graphql' => true and the fields have values set. However GraphQL returns null on all of the fields.

Steps to reproduce

Create options page:

acf_add_options_page(
        array(
            'page_title' => 'Theme Settings',
            'menu_title' => 'Theme',
            'menu_slug'  => 'theme-settings',
            'capability' => 'manage_options',
            'post_id'    => 'theme-settings',
            'redirect'   => false,
            'show_in_graphql' => true,
        )
 );

Added a text field called newsletterTitle to the options page. GraphQL is:

query {
  themeSettings {
    newsletterTitle
  }
}

This returns "Cannot query field "newsletterTitle" on type "ThemeSettings"."

I then enabled the "Show in GraphQL" toggle in the field group in ACF and set the type name as optionsTheme. Update the graphql to the following:

query {
  themeSettings {
    optionsTheme {
      newsletterTitle
    }
  }
}

newsletterTitle then returns null

PHP or JSON export of the ACF Field Group(s)

[
    {
        "qef_simple_location_rules": 0,
        "key": "group_65395bec23118",
        "title": "Theme Settings",
        "fields": [
            {
                "allow_backendsearch": false,
                "show_column_filter": false,
                "allow_bulkedit": false,
                "allow_quickedit": false,
                "show_column": false,
                "show_column_weight": 1000,
                "show_column_sortable": false,
                "key": "field_65395bec3a18b",
                "label": "Resources",
                "name": "",
                "aria-label": "",
                "type": "tab",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "graphql_field_name": "primary",
                "wpml_cf_preferences": 3,
                "placement": "top",
                "endpoint": 0
            },
            {
                "allow_backendsearch": false,
                "show_column_filter": false,
                "allow_bulkedit": false,
                "allow_quickedit": false,
                "show_column": false,
                "show_column_weight": 1000,
                "show_column_sortable": false,
                "key": "field_65395d283a18d",
                "label": "Left Column Title",
                "name": "left_column_title",
                "aria-label": "",
                "type": "text",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "wpml_cf_preferences": 2,
                "default_value": "",
                "maxlength": "",
                "placeholder": "",
                "prepend": "",
                "append": "",
                "show_in_graphql": 1,
                "graphql_description": "",
                "graphql_field_name": "leftColumnTitle",
                "graphql_non_null": 0
            },
            {
                "allow_backendsearch": false,
                "show_column_filter": false,
                "allow_bulkedit": false,
                "allow_quickedit": false,
                "show_column": false,
                "show_column_weight": 1000,
                "show_column_sortable": false,
                "key": "field_65395d323a18e",
                "label": "Left Column Items",
                "name": "left_column_items",
                "aria-label": "",
                "type": "repeater",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "wpml_cf_preferences": 3,
                "layout": "row",
                "pagination": 0,
                "min": 0,
                "max": 0,
                "collapsed": "",
                "button_label": "Add Item",
                "show_in_graphql": 1,
                "graphql_description": "",
                "graphql_field_name": "",
                "graphql_non_null": 0,
                "rows_per_page": 20,
                "sub_fields": [
                    {
                        "allow_backendsearch": false,
                        "show_column_filter": false,
                        "allow_bulkedit": false,
                        "allow_quickedit": false,
                        "show_column": false,
                        "show_column_weight": 1000,
                        "show_column_sortable": false,
                        "key": "field_65395d403a18f",
                        "label": "Icon",
                        "name": "icon",
                        "aria-label": "",
                        "type": "image",
                        "instructions": "",
                        "required": 0,
                        "conditional_logic": 0,
                        "wrapper": {
                            "width": "",
                            "class": "",
                            "id": ""
                        },
                        "wpml_cf_preferences": 3,
                        "return_format": "array",
                        "library": "all",
                        "min_width": "",
                        "min_height": "",
                        "min_size": "",
                        "max_width": "",
                        "max_height": "",
                        "max_size": "",
                        "mime_types": "",
                        "preview_size": "medium",
                        "show_in_graphql": 1,
                        "graphql_description": "",
                        "graphql_field_name": "icon",
                        "parent_repeater": "field_65395d323a18e"
                    },
                    {
                        "allow_backendsearch": false,
                        "show_column_filter": false,
                        "allow_bulkedit": false,
                        "allow_quickedit": false,
                        "show_column": false,
                        "show_column_weight": 1000,
                        "show_column_sortable": false,
                        "key": "field_65395d4e3a190",
                        "label": "Title",
                        "name": "title",
                        "aria-label": "",
                        "type": "text",
                        "instructions": "",
                        "required": 1,
                        "conditional_logic": 0,
                        "wrapper": {
                            "width": "",
                            "class": "",
                            "id": ""
                        },
                        "wpml_cf_preferences": 2,
                        "default_value": "",
                        "maxlength": "",
                        "placeholder": "",
                        "prepend": "",
                        "append": "",
                        "show_in_graphql": 1,
                        "graphql_description": "",
                        "graphql_field_name": "title",
                        "graphql_non_null": 0,
                        "parent_repeater": "field_65395d323a18e"
                    },
                    {
                        "allow_backendsearch": false,
                        "show_column_filter": false,
                        "allow_bulkedit": false,
                        "allow_quickedit": false,
                        "show_column": false,
                        "show_column_weight": 1000,
                        "show_column_sortable": false,
                        "key": "field_65395d573a191",
                        "label": "Description",
                        "name": "description",
                        "aria-label": "",
                        "type": "text",
                        "instructions": "",
                        "required": 0,
                        "conditional_logic": 0,
                        "wrapper": {
                            "width": "",
                            "class": "",
                            "id": ""
                        },
                        "wpml_cf_preferences": 2,
                        "default_value": "",
                        "maxlength": "",
                        "placeholder": "",
                        "prepend": "",
                        "append": "",
                        "show_in_graphql": 1,
                        "graphql_description": "",
                        "graphql_field_name": "description",
                        "graphql_non_null": 0,
                        "parent_repeater": "field_65395d323a18e"
                    },
                    {
                        "allow_backendsearch": false,
                        "show_column_filter": false,
                        "allow_bulkedit": false,
                        "allow_quickedit": false,
                        "show_column": false,
                        "show_column_weight": 1000,
                        "show_column_sortable": false,
                        "key": "field_65395d5d3a192",
                        "label": "Link",
                        "name": "link",
                        "aria-label": "",
                        "type": "link",
                        "instructions": "",
                        "required": 1,
                        "conditional_logic": 0,
                        "wrapper": {
                            "width": "",
                            "class": "",
                            "id": ""
                        },
                        "wpml_cf_preferences": 3,
                        "return_format": "array",
                        "show_in_graphql": 1,
                        "graphql_description": "",
                        "graphql_field_name": "link",
                        "graphql_non_null": 0,
                        "parent_repeater": "field_65395d323a18e"
                    }
                ]
            },
            {
                "allow_backendsearch": false,
                "show_column_filter": false,
                "allow_bulkedit": false,
                "allow_quickedit": false,
                "show_column": false,
                "show_column_weight": 1000,
                "show_column_sortable": false,
                "key": "field_65395d723a193",
                "label": "Right Column Title",
                "name": "right_column_title",
                "aria-label": "",
                "type": "text",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "wpml_cf_preferences": 2,
                "default_value": "",
                "maxlength": "",
                "placeholder": "",
                "prepend": "",
                "append": "",
                "show_in_graphql": 1,
                "graphql_description": "",
                "graphql_field_name": "rightColumnTitle",
                "graphql_non_null": 0
            },
            {
                "allow_backendsearch": false,
                "show_column_filter": false,
                "allow_bulkedit": false,
                "allow_quickedit": false,
                "show_column": false,
                "show_column_weight": 1000,
                "show_column_sortable": false,
                "key": "field_65395dad3a195",
                "label": "Topics",
                "name": "topics",
                "aria-label": "",
                "type": "taxonomy",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "wpml_cf_preferences": 3,
                "taxonomy": "topic",
                "add_term": 0,
                "save_terms": 0,
                "load_terms": 0,
                "return_format": "object",
                "field_type": "checkbox",
                "bidirectional": 0,
                "show_in_graphql": 1,
                "graphql_description": "",
                "graphql_field_name": "topics",
                "multiple": 0,
                "allow_null": 0,
                "bidirectional_target": []
            },
            {
                "allow_backendsearch": false,
                "show_column_filter": false,
                "allow_bulkedit": false,
                "allow_quickedit": false,
                "show_column": false,
                "show_column_weight": 1000,
                "show_column_sortable": false,
                "key": "field_655e6f37b918e",
                "label": "Footer",
                "name": "",
                "aria-label": "",
                "type": "tab",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "graphql_field_name": "footer",
                "wpml_cf_preferences": 3,
                "placement": "top",
                "endpoint": 0
            },
            {
                "allow_backendsearch": 0,
                "show_column_filter": false,
                "allow_bulkedit": 0,
                "allow_quickedit": 0,
                "show_column": 0,
                "show_column_weight": 1000,
                "show_column_sortable": false,
                "key": "field_655e6f47b918f",
                "label": "Newsletter Title",
                "name": "newsletter_title",
                "aria-label": "",
                "type": "text",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "wpml_cf_preferences": 2,
                "default_value": "",
                "maxlength": "",
                "placeholder": "",
                "prepend": "",
                "append": "",
                "show_in_graphql": 1,
                "graphql_description": "",
                "graphql_field_name": "newsletterTitle",
                "graphql_non_null": 0
            },
            {
                "allow_backendsearch": false,
                "show_column_filter": false,
                "allow_bulkedit": false,
                "allow_quickedit": false,
                "show_column": false,
                "show_column_weight": 1000,
                "show_column_sortable": false,
                "key": "field_655e6f50b9190",
                "label": "Newsletter Description",
                "name": "newsletter_description",
                "aria-label": "",
                "type": "textarea",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "wpml_cf_preferences": 2,
                "default_value": "",
                "maxlength": "",
                "rows": 3,
                "placeholder": "",
                "new_lines": "",
                "show_in_graphql": 1,
                "graphql_description": "",
                "graphql_field_name": "newsletterDescription",
                "graphql_non_null": 0
            }
        ],
        "location": [
            [
                {
                    "param": "options_page",
                    "operator": "==",
                    "value": "theme-settings"
                }
            ]
        ],
        "menu_order": 0,
        "position": "normal",
        "style": "default",
        "label_placement": "top",
        "instruction_placement": "label",
        "hide_on_screen": "",
        "active": true,
        "description": "",
        "show_in_rest": 0,
        "acfml_field_group_mode": "localization",
        "show_in_graphql": 0,
        "graphql_field_name": "optionsTheme",
        "map_graphql_types_from_location_rules": 0,
        "graphql_types": ""
    }
]

Additional context

No response

WPGraphQL Version

1.19.0

WPGraphQL For ACF Version

2.0.0-beta.6.0.0

ACF (Advanced Custom Fields) Version. Free or Pro?

Pro

WordPress Version

6.4.1

PHP Version

8.1

Additional enviornment details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL, WPGraphQL For ACF, ACF, etc.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

Labels

type: bugIssue that causes incorrect or unexpected behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions