wpgraphql-acf icon indicating copy to clipboard operation
wpgraphql-acf copied to clipboard

Nested page link field returning null

Open tablufc88 opened this issue 1 year ago • 6 comments

Description

I have a flexible content field where I'm creating galleries and adding a "page_link" field to choose multiple pages for the gallery to be shown on. Since upgrading from wp-graphql-acf to wpgraphql-acf, it is always returning null rather than an array of page links.

Steps to reproduce

Possibly related to this

  1. Create options page for galleries:
[
            'page_title' => 'Galleries',
            'menu_title' => 'Galleries',
            'menu_slug' => 'galleries',
            'capability' => 'edit_posts',
            'redirect' => false,
            'position' => 2,
            'icon_url' => 'dashicons-format-gallery',
            'show_in_graphql' => true,
]
  1. Import the field group json file

  2. Populate some content

  3. Query the field:

query galleryShowOns {
    galleries {
      galleries2 {
        galleries {
          ... on Galleries2GalleriesGalleryLayout {
            title
            showOn {
              edges {
                node {
                  id
                  uri
                }
              }
            }
          }
        }
      }
    }
  }

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

{
    "key": "group_63ff34a068856",
    "title": "Galleries",
    "fields": [
        {
            "key": "field_63ff34c95bfc2",
            "label": "Galleries",
            "name": "galleries",
            "aria-label": "",
            "type": "flexible_content",
            "instructions": "Manage all the website galleries here. Enter a title for each gallery and remember to choose which pages to show the gallery on.",
            "required": 0,
            "conditional_logic": 0,
            "wrapper": {
                "width": "",
                "class": "",
                "id": ""
            },
            "show_in_graphql": 1,
            "layouts": {
                "layout_63ff34da33bd4": {
                    "key": "layout_63ff34da33bd4",
                    "name": "gallery",
                    "label": "Gallery",
                    "display": "block",
                    "sub_fields": [
                        {
                            "key": "field_63ff34e85bfc3",
                            "label": "Title",
                            "name": "title",
                            "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_63fffccdd9b0b",
                            "label": "Show on",
                            "name": "show_on",
                            "aria-label": "",
                            "type": "page_link",
                            "instructions": "Choose which pages to show this gallery on",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "post_type": [
                                "page"
                            ],
                            "post_status": "",
                            "taxonomy": "",
                            "allow_archives": 1,
                            "multiple": 1,
                            "allow_null": 0,
                            "show_in_graphql": 1,
                            "graphql_description": "",
                            "graphql_field_name": "showOn",
                            "graphql_connection_type": "one_to_many"
                        },
                        {
                            "key": "field_63ff35025bfc4",
                            "label": "Images",
                            "name": "images",
                            "aria-label": "",
                            "type": "gallery",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "return_format": "array",
                            "preview_size": "medium",
                            "insert": "append",
                            "library": "all",
                            "min": "",
                            "max": "",
                            "min_width": "",
                            "min_height": "",
                            "min_size": "",
                            "max_width": "",
                            "max_height": "",
                            "max_size": "",
                            "mime_types": ""
                        }
                    ],
                    "min": "",
                    "max": ""
                }
            },
            "button_label": "Add gallery",
            "min": "",
            "max": ""
        }
    ],
    "location": [
        [
            {
                "param": "options_page",
                "operator": "==",
                "value": "galleries"
            }
        ]
    ],
    "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": "galleries2",
    "map_graphql_types_from_location_rules": 0,
    "graphql_types": "",
    "modified": 1713487960
}

Additional context

No response

WPGraphQL Version

1.23.0

WPGraphQL For ACF Version

2.2.0

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

Pro

WordPress Version

6.5.2

PHP Version

8.1.27

Additional enviornment details

No response

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

  • [X] Yes

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

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

tablufc88 avatar Apr 19 '24 04:04 tablufc88

I can confirm this issue with very similar versions.

Repeater field with a link field inside on an option page.

mawiswiss avatar May 30 '24 16:05 mawiswiss

I was working through the upgrade guide on a very spare site (mostly just ACF Pro 6.3.0.1, wpgql 1.26.0 and wpgql-acf at 2.2.0 on wp 6.5.3) and found a very similar thing; for a simple repeater, each a single image, attached via the options page (no post_id in the setup) I get the correct number of nodes (8 images in the repeater) under the correct/expected GQL structure, but all as null.

I’ve reverted back to 0.6.1 for now.

mckelvey avatar Jun 01 '24 19:06 mckelvey

I have also had this problem, and found that the issue extends to both the File and Post Object field types. The file returns null, while the edges and node arrays inside the Post Object return empty.

gnathang avatar Jun 03 '24 13:06 gnathang

+1

cavemon avatar Aug 30 '24 19:08 cavemon

Same issue here, page_link within a repeater filed returns null.

gridig avatar Sep 03 '24 14:09 gridig

+1

"links": [
              {
                "link": {
                  "__typename": "AcfLink",
                  "url": null,
                  "title": null
                }
              },
              {
                "link": {
                  "__typename": "AcfLink",
                  "url": null,
                  "title": null
                }
              },

Are there any rough estimates of when this might be done? Or should I back to this plugin WPGraphQL for Advanced Custom Fields - Adds Advanced Custom Fields to the WPGraphQL SchemaVersion 0.6.1 | By WPGraphQL, Jason Bahl 

VovaChampion avatar Apr 29 '25 13:04 VovaChampion