-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fields inside repeater return null and/or empty arrays: Link, File and Post Object #208
Comments
please let me know what other info you need for the reproduction :) |
This issue is holding us back from migrating to the new plugin. Here's a very minimal reproduction if that's helpful (our implementation is via blocks but seems to still be an issue with a normal acf field group which this includes): https://www.dropbox.com/scl/fi/llfjlg1vm0akppue0ulpy/ACF-Repeater-Fields.zip?rlkey=g7z0t11zu78on7lq52puf1g30&st=43twx36g&dl=0 (this is a zip generated from LocalWP). The username and password is |
@gnathang when I tried to reproduce, I started by importing your ACF Field Group, but I get the following debug message:
I will fix that field group config and try again, but wanted to point that out. |
@gnathang after updating the name of the layout to "two_col_text" I then saved data in the flex field: And was able to query and see results: I tried to reproduce with the following:
|
@ttstauss it looks like the issue with the "Page Link" field is different than the issue opened here. It looks like WPGraphQL for ACF is mistakenly mapping the PageLink field type to a connection, but that's not actually how the ACF Page Link Field is intended to be used. see: https://www.advancedcustomfields.com/resources/page-link/#template-usage The page link field is intended to return a link (string) and not an object representing the page. I think we should open a separate issue to fix the Type mapping for the ACF "Page Link" field type as it should return a string and not a Connection as it currently does, as ACF does not return data that can be used to resolve a connection, instead it returns a url. |
Thanks, @jasonbahl! That makes total sense. |
thanks both! will try this out now. is it this same problem that makes the file and post object field types return null also? and does it have anything to do with being inside a repeater? because elsewhere it seems to work fine! |
@gnathang can you elaborate? fields on repeaters appear to be working as expected for me: I can add data to a repeater within a flex field using the ACF Field Group export you shared: And I can query and get values, as expected, for the fields: If you're getting null values, I would recommend:
if there's an issue with file and post object field types, it would be good to provide an isolated reproduction in a new issue. Can you reproduce it with just WPGraphQL + ACF + WPGraphQL for ACF active and nothing else? Does it happen with just a simple field group or only with more complex field group setups? For example, I've seen some issues arise because different field groups have the same graphql_field_name as another field group and things get weird. |
Sorry for the slow reply. I have now returned some values for the Page Link field! Having trouble with null results elsewhere, but will reach out to Discord and discussions first. Thank you all for your help! |
Hey @gnathang, if you can expand on the troubles you are having, we would love to see if we can get this resolved. The more info you can share the better 🙌🏼 |
Hey @jasonbahl and @josephfusco, I wanted to share my experience regarding this issue. We’re currently working on a client project where we need to update WPGraphQL for ACF from version 0.6.2 to 2.4.1, but we’re blocked by this specific issue. I set up a new WordPress project using DDEV and managed to replicate the problem by matching the configuration from our client project. We’re primarily using ACF fields, particularly the Link type, to add submenu items to the header navigation. To thoroughly test this, I enhanced the example to include all the field types with reported error on this thread, and I can confirm that the issue persists with Link, Page Link, and File fields. Here’s a snapshot of the ACF fields setup: And here are the query results: We would greatly appreciate any help resolving this issue, especially with the Link field, as it’s crucial for our menu. We’ve been stuck on this migration for a while, so any insights would be valuable. Thank you in advance! :) Steps to Reproduce
Versions
|
Description
Hiya, I'm using Next.js and WPGraphQL/Apollo in a headless WP system using Colby Faycock's great starter.
I think this issue has already been flagged, but I think that nested Link, File and Post Object field types return null, or produce empty edges and nodes arrays, in the case of Post Object.
With the Link field it seems that the field name is being renamed 'pageLink' every time. (In my fields, this field is named as slideLink). All other ACF field types I've used so far seem to work fine.
An example ACF structure, if it helps: Flex (field group) > Flex (flexible content) > Text Slides (flexible content layout) > Slides (repeater) > SlideLink (link field).
I'm not sure if the 'make non-null' option has anything to do this this or not!
Here's some screenshots in GraphiQL IDE in the order Link, File and Post Object (with console log).
Thank you!
Steps to reproduce
here's the query i'm using in my next.js app:
query PageByUri($uri: ID!) { page(id: $uri, idType: URI) { flex { fieldGroupName flex { ... on FlexFlexTextSlidesLayout { fieldGroupName layout thisIsALink { target url title } slides { bigTitle smallTitle textBody video { cursor node { sourceUrl(size: BANNER) srcSet(size: BANNER) uri sizes(size: BANNER) } } image { cursor node { altText sizes(size: BANNER) sourceUrl(size: BANNER) srcSet(size: BANNER) uri } } } } ... on FlexFlexWayfinderLayout { fieldGroupName introText layout smallTitle title link { target title url } signposts { fieldGroupName pagePost { edges { cursor } nodes { ... on Post { id featuredImage { cursor node { altText srcSet(size: BANNER) sourceUrl(size: BANNER) } } title(format: RAW) postId link } slug uri ... on Page { featuredImage { cursor node { altText sourceUrl(size: BANNER) srcSet(size: BANNER) uri } } content(format: RAW) id } } } } } } } } }
__
PHP or JSON export of the ACF Field Group(s)
acf-export-2024-06-03.json
Additional context
No response
WPGraphQL Version
Version 1.26.0
WPGraphQL For ACF Version
Version 2.2.0
ACF (Advanced Custom Fields) Version. Free or Pro?
7.3.0.1, Pro
WordPress Version
6.5.3
PHP Version
8.4 (tried on 8.0 too, but didn't work!)
Additional enviornment details
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL, WPGraphQL For ACF, ACF, etc.
The text was updated successfully, but these errors were encountered: