Skip to content

WPGraphQL Gutenberg ACF Taxonomy Field Return #133

@jsimondshiebing

Description

@jsimondshiebing

Description

Using the most recent version of this plugin the Taxonomy field type returns an array of all taxonomy term objects regardless of the values you set for the field. In the ACF the Taxonomy field has the option to select a specific Taxonomy to pull terms from (either a built in like Post Categories or a custom Taxonomy). You can also specify the return type to be either the Term Object or the Term ID. However regardless of what is selected here the query in GraphQL always resolves to an array of all of the Term Objects regardless of Taxonomy.

Steps to reproduce

  1. Create or edit an ACF Field Group.
  2. Create or edit a field of type Taxonomy
  3. Set the field's Taxonomy option to a list that contains valid Terms.
  4. Connect the ACF Field Group to a Gutenberg Block.
  5. Add the ACF Block to a page/post and set the field's value.
  6. Query the page's editorBlocks for the Taxonomy field.
  7. Should return either the Term Object or the Term ID of the value set on the block, however currently returns all terms.

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

[
    {
        "key": "group_62bb6efc4104c",
        "title": "Work Section",
        "fields": [
            {
                "key": "field_62bb6f210bc95",
                "label": "Heading",
                "name": "heading",
                "aria-label": "",
                "type": "text",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "show_in_graphql": 1,
                "default_value": "",
                "placeholder": "",
                "prepend": "",
                "append": "",
                "maxlength": ""
            },
            {
                "key": "field_62e1a46d2808f",
                "label": "Text",
                "name": "text",
                "aria-label": "",
                "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_62e1a39172382",
                "label": "Layout",
                "name": "layout",
                "aria-label": "",
                "type": "select",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "show_in_graphql": 1,
                "choices": {
                    "full": "Full Width",
                    "large": "Large Cards",
                    "medium": "Medium Cards",
                    "small": "Small Cards"
                },
                "default_value": "full",
                "allow_null": 0,
                "multiple": 0,
                "ui": 0,
                "return_format": "value",
                "ajax": 0,
                "placeholder": ""
            },
            {
                "key": "field_62e2c80dd16d7",
                "label": "Category",
                "name": "category",
                "aria-label": "",
                "type": "taxonomy",
                "instructions": "",
                "required": 1,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "taxonomy": "work-categories",
                "add_term": 0,
                "save_terms": 0,
                "load_terms": 0,
                "return_format": "object",
                "field_type": "select",
                "allow_null": 1,
                "bidirectional": 0,
                "show_in_graphql": 1,
                "graphql_description": "",
                "graphql_field_name": "category",
                "multiple": 0,
                "bidirectional_target": []
            },
            {
                "key": "field_62bb6f390bc96",
                "label": "Total Items",
                "name": "total_items",
                "aria-label": "",
                "type": "select",
                "instructions": "Total number of most recent Work items to show.",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "show_in_graphql": 1,
                "choices": {
                    "1": "1",
                    "2": "2",
                    "3": "3",
                    "4": "4",
                    "5": "5"
                },
                "default_value": 5,
                "allow_null": 1,
                "multiple": 0,
                "ui": 0,
                "return_format": "value",
                "ajax": 0,
                "placeholder": ""
            },
            {
                "key": "field_62bb6fb9632e4",
                "label": "Button",
                "name": "button",
                "aria-label": "",
                "type": "link",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "show_in_graphql": 1,
                "return_format": "array"
            }
        ],
        "location": [
            [
                {
                    "param": "block",
                    "operator": "==",
                    "value": "acf\/work-section"
                }
            ]
        ],
        "menu_order": 0,
        "position": "normal",
        "style": "default",
        "label_placement": "top",
        "instruction_placement": "label",
        "hide_on_screen": "",
        "active": true,
        "description": "",
        "show_in_rest": 0,
        "show_in_graphql": 1,
        "graphql_field_name": "workSection",
        "map_graphql_types_from_location_rules": 1,
        "graphql_types": [
            "AcfWorkSection"
        ]
    }
]

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?

6.2.4, Pro

WordPress Version

6.3.2

PHP Version

7.4

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

close candidateNeeds confirmation before closingneeds: reproductionThis issue needs to be reproduced independently

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions