Open gnathang opened 1 month ago
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 test
.
@gnathang when I tried to reproduce, I started by importing your ACF Field Group, but I get the following debug message:
The ACF Field or Field Group could not be added to the schema. GraphQL Field and Type names cannot start with a number
"key": "layout_620295a0f3b18",
"name": "2_col_text",
"label": "2 Column Text",
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.
@ttstauss I opened a new issue related to the PageLink field specifically: https://github.com/wp-graphql/wpgraphql-acf/issues/213
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!
is it this same problem that makes the file and post object field types return null also?
@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 🙌🏼
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.