-
Notifications
You must be signed in to change notification settings - Fork 122
Acf fields return null with repeater/group #170
Comments
Yeah this not only occurs with the "Repeater" field type but also the "Group" and "Gallery" field types. It gets quite annoying when you have to rename each field that has child nodes. |
Note that this was working fine in
|
Correction, I am no longer to replicate the issue. My problem was that my DB was broken and the ACFs did indeed have no content any longer. After restoring the DB I can see values of repeater fields even if multiple sub-fields have the same name. |
ok, now I can replicate it again with wp-graphql-acf 0.3.5. I have 2 custom fields which have the same named repeater, lets say they are called Both of them have a repeater field called On the page itself only If I only query query {
page(id: "8796053", idType: DATABASE_ID) {
id
slug
title
acf2 {
links {
buttonText
}
}
}
} => "data": {
"page": {
"id": "cG9zdDo4Nzk2MDUz",
"slug": "my-page",
"title": "my page",
"acf2": {
"links": [
{
"buttonText": "my button text"
},
... however if I query both fields (even though on the page query {
page(id: "8796053", idType: DATABASE_ID) {
id
slug
title
acf1 {
links {
buttonText
}
}
acf2 {
links {
buttonText
}
}
}
} => "data": {
"page": {
"id": "cG9zdDo4Nzk2MDUz",
"slug": "my-page",
"title": "my page",
"acf1": {
"links": [
{
"buttonText": "my button text"
},
...
"acf2": {
"links": [
{
"buttonText": null
},
{
"buttonText": null
}, |
I think I tracked down the problem to be an ACF bug, when you query
and the So this is most likely an ACF caching bug that does not have a lot to do with wp-graphql-acf (or rather where wp-graphql-acf cannot really work around this problem). |
I managed to work around the caching problem by patching |
- this avoids having groups with the same field names from clashing - in the case where you query via `wp-graphql-acf` and you have multiple field groups with repeaters that resolve to the same field name, then without this patch the first field group will load the field value and store it inside the cache with the wrong sub-field ids. - for more info see wp-graphql/wp-graphql-acf#170
- this avoids having groups with the same field names from clashing - in the case where you query via `wp-graphql-acf` and you have multiple field groups with repeaters that resolve to the same field name, then without this patch the first field group will load the field value and store it inside the cache with the wrong sub-field ids. - for more info see wp-graphql/wp-graphql-acf#170
created a patch for ACF, lets see if they take it |
@rburgst I guess it's a bit different issue you're talking about. In my case, if there are multiple objects in DB with the same ACF groups/repeaters names there is some overlapping problem when it just does not show fields. So for the time being the workaround just name those groups differently. |
I believe your problem is exactly the same as mine. As stated above, the problem is wrong caching, the cache is stored with the wrong field id. In my case I also get all |
you can try out my patch (AdvancedCustomFields/acf#403) and see if it helps. |
@rburgst @lnikell we've been discussing changing how field groups are mapped to the GraphQL Schema, and I hope the changes to that will resolve this. Right now this plugin tries to interpret the ACF location rules and attempt to map to the WPGraphQL Schema, but there are a lot of things that don't map really well, and issues like this come up. I believe that if we can better validate what field groups are assigned to which Types in the GraphQL Schema, this should resolve this issue. I've added this issue to the "ACF Schema Location Rules" milestone so we can keep it top of mind as we work on that problem. |
@jasonbahl Thanks for the update. Looking forward to try new version, one it’s released. |
@lnikell @rburgst Hey! I'm preparing v0.5.0 for release (#250). It has better support for mapping Field Groups to specific Types in the Schema and an option for you to explicitly set which GraphQL Types the Field Group should show on. If you could test with that release, that would be sweet! Thanks! |
@jasonbahl I rechecked with 0.5.0 and my problem persists, so my patch in AdvancedCustomFields/acf#403 is still required |
Closing this as there's been no response since May 2021 |
I would also recommend checking out the new version of the plugin being built over here: https://github.com/wp-graphql/wpgraphql-acf. It's the version that will be released to WordPress.org and then this repo will be archived. |
I have the following problem, that I think relates to this plugin:
ACF version - 5.8.12
WP GraphQL - 0.12.3
WPGraphQL for Advanced Custom Fields - 0.3.5 (Tested on 0.4 too)
Custom Post Type UI - 1.8.0
The text was updated successfully, but these errors were encountered: