Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

ACF Options fields null in Schema after latest update (v0.5.0) #254

Closed
danwebb13 opened this issue Apr 23, 2021 · 6 comments · Fixed by #257
Closed

ACF Options fields null in Schema after latest update (v0.5.0) #254

danwebb13 opened this issue Apr 23, 2021 · 6 comments · Fixed by #257
Assignees
Labels
bug Something isn't working

Comments

@danwebb13
Copy link

So excited about the new location rules changes, but I think this may be a new bug.

I have an Options page in Wordpress, provided custom fields by ACF. These fields were previously shown in the GraphQL schema.
After updating to version 0.5.0, those fields now show as 'null' instead of their actual value in the schema.
I can't seem to find a way around this.

@jonlow
Copy link

jonlow commented Apr 26, 2021

Can confirm this is also happening to me too as per discussion on wpgraphql slack https://wp-graphql.slack.com/archives/C5X592Z99/p1619145882096700

This is how I'm registering the options page

acf_add_options_page(
        [
            'page_title' => 'Site Options',
            'menu_title' => 'Site Options',
            'menu_slug'  => 'headless-settings',
            'capability' => 'manage_options',
            'post_id'    => 'headless-settings',
            'redirect'   => false,
            'graphql_field_name' => 'headlessOptions',
            'show_in_graphql' => true
        ]
    )

And my field group json

{
    "key": "group_5de5da9d2307f",
    "title": "Site Settings",
    "fields": [
        {
            "key": "field_5e5deaca2de4f",
            "label": "Footer",
            "name": "",
            "type": "tab",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "placement": "top",
            "endpoint": 0
        },
        {
            "key": "field_5ee6df09f1f02",
            "label": "Text",
            "name": "footer_text",
            "type": "wysiwyg",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "default_value": "",
            "tabs": "all",
            "toolbar": "full",
            "media_upload": 1,
            "delay": 0
        },
        {
            "key": "field_5ee6dff392978",
            "label": "Links",
            "name": "footer_links",
            "type": "relationship",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "post_type": [
                "page"
            ],
            "taxonomy": "",
            "filters": "",
            "elements": "",
            "min": "",
            "max": "",
            "return_format": "object"
        },
        {
            "key": "field_5f0fa7d0d9035",
            "label": "Social Links",
            "name": "",
            "type": "tab",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "placement": "top",
            "endpoint": 0
        },
        {
            "key": "field_5f0fa7e0d9036",
            "label": "Facebook",
            "name": "facebook_link",
            "type": "text",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "default_value": "",
            "placeholder": "",
            "prepend": "",
            "append": "",
            "maxlength": ""
        },
        {
            "key": "field_5f0fa7edd9038",
            "label": "Instagram",
            "name": "instagram_link",
            "type": "text",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "default_value": "",
            "placeholder": "",
            "prepend": "",
            "append": "",
            "maxlength": ""
        },
        {
            "key": "field_5f0fa7e7d9037",
            "label": "LinkedIn",
            "name": "linkedin_link",
            "type": "text",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "default_value": "",
            "placeholder": "",
            "prepend": "",
            "append": "",
            "maxlength": ""
        },
        {
            "key": "field_5f0fa7f2cb24f",
            "label": "Twitter",
            "name": "twitter_link",
            "type": "text",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "default_value": "",
            "placeholder": "",
            "prepend": "",
            "append": "",
            "maxlength": ""
        },
        {
            "key": "field_5f1003d454c08",
            "label": "Contact enquiries",
            "name": "",
            "type": "tab",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "placement": "top",
            "endpoint": 0
        },
        {
            "key": "field_5f1003fd54c0a",
            "label": "Email Recipient",
            "name": "email_enquiry",
            "type": "text",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "default_value": "",
            "placeholder": "",
            "prepend": "",
            "append": "",
            "maxlength": ""
        },
        {
            "key": "field_6029d78ff5bb2",
            "label": "Address",
            "name": "address",
            "type": "text",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "default_value": "",
            "placeholder": "",
            "prepend": "",
            "append": "",
            "maxlength": ""
        },
        {
            "key": "field_6029d796f5bb3",
            "label": "Phone",
            "name": "phone",
            "type": "text",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "default_value": "",
            "placeholder": "",
            "prepend": "",
            "append": "",
            "maxlength": ""
        },
        {
            "key": "field_6029d9126f036",
            "label": "Map Image",
            "name": "map_image",
            "type": "image",
            "instructions": "",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "return_format": "array",
            "preview_size": "medium",
            "library": "all",
            "min_width": "",
            "min_height": "",
            "min_size": "",
            "max_width": "",
            "max_height": "",
            "max_size": "",
            "mime_types": ""
        }
    ],
    "location": [
        [
            {
                "param": "options_page",
                "operator": "==",
                "value": "headless-settings"
            }
        ]
    ],
    "menu_order": 0,
    "position": "normal",
    "style": "default",
    "label_placement": "top",
    "instruction_placement": "label",
    "hide_on_screen": "",
    "active": true,
    "description": "",
    "show_in_graphql": 1,
    "graphql_field_name": "siteSettings",
    "modified": 1613355290
}

@lindvall
Copy link

I experienced the same problem, and think I may have found the issue.

After adding
"type" => "options_page",
to the ACF options page definition, data is returned properly.

That parameter seems to be defining how data is returned from options pages here:

case is_array( $root ) && ! empty( $root['type'] ) && 'options_page' === $root['type']:

IMO should either the logic be updated or the "type" requirement be added to the docs.
Perhaps something has changed in an ACF update?

@jasonbahl
Copy link
Contributor

@lindvall thanks for the added context here.

I'll look into this and see if we can resolve it, either in code or in documentation.

@alexadark
Copy link

Hi, same problem here
thanks @lindvall it fix the problem 👍

@jasonbahl
Copy link
Contributor

👋🏻 Hey!

Apologies for this regression!

I've got this fixed (and tested properly) in #257. Will get this released shortly!

@jasonbahl jasonbahl self-assigned this Apr 28, 2021
@jasonbahl jasonbahl added the bug Something isn't working label Apr 28, 2021
@jasonbahl jasonbahl added this to the ACF Schema Location Rules milestone Apr 28, 2021
jasonbahl added a commit that referenced this issue Apr 28, 2021
…null

#254 - add back missing type declaration for options pages.
@jasonbahl
Copy link
Contributor

This has been released as v0.5.2

https://github.com/wp-graphql/wp-graphql-acf/releases/tag/v0.5.2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants