-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Description
I am building a headless Wordpress site using Next.js and started from a fresh Wordpress installation with a minimal custom theme setup.
Almost everything is working fine and I tested the preview functionality early on to ensure everything works smooth, as I know this can be tricky in headless setups.
But now I encountered a very strange behavior of the wpgraphql-acf plugin, regarding the preview functionality:
Generally the preview query returns the correct fields and they contain some data. But the data they contain is not reflecting the current preview state – instead it is showing the value of the field from the last publish. Now this is only happening with some ACF field types. Also some fields are inconsistent in behavior – so sometimes the preview data is correct, in other scenarios it is not.
Specifically, two problematic patterns emerged from my testing:
1) ACF file fields (e.g. file and images) don't update at all after removing/changing them and hitting the preview field. But only on top level, not inside repeater/flex fields
2) After a while of editing, saving and hitting the preview button, it seems that all fields are not updating correctly: When refreshing the page, changing the data and hitting the preview button, the graphQl data still shows the unchanged data. After hitting the preview button a second time, the query then shows the correct data (except for file type fields, see 1).
Doing some testing, I would guess it has to do with the number of revisions, because the inconsistency seem to increase after hitting the preview button several times.
I encountered this in the middle of a project but tested it again on a minimal setup:
• Fresh Worpress installation running on localhost via MAMP
• Fresh DB
• Fresh and minimal custom theme
• Only the necessary plugins in their newest versions are active: Advanced Custom Fields PRO, Classic Editor, WPGraphQL, WPGraphQL for ACF
• Created one Example test page
• Created ACF fields to test: text, image, file, url, WYSIWYG-Editor, repeater, flex
Steps to reproduce
- Setup Wordpress, ACF Pro, GraphQl
- Create an example page and and ACF fields. I attached my example acf field configuration (afc-export.json)
To reproduce the first strange behavior: not updating file data, while the rest works:
- Populate the example page ACF fields with Data A
- Save the page
- Query Data via GraphiQl interface (authenticated user, asPreview=true)
- Change Data from A to B for all ACF fields
- Hit Preview Button
- Query Data via GraphiQl interface (authenticated user, asPreview=true)
- Remove all data from page
- Hit Preview Button
- Query Data via GraphiQl interface (authenticated user, asPreview=true)
- Notice that the files in the graphQl data have not changed, they are still present even though they were deleted from the page before hitting the preview button.
To reproduce the second strange behavior: not updating any data that have been working before, after refreshing the page and hitting the preview button once, then query the data:
-
After changing the data some repeatedly, hitting the preview button and testing the behaviour changes:
-
Set All page data to A, save
- Query data via graphQl
- Refresh the page
- Change all data to B
- hit the preview button, query data again
- Notice that the graphQl Data didn't change. It should be B now but it is still A.
PHP or JSON export of the ACF Field Group(s)
Additional context
No response
WPGraphQL Version
1.22.0
WPGraphQL For ACF Version
2.1.2
ACF (Advanced Custom Fields) Version. Free or Pro?
6.2. (Pro)
WordPress Version
6.4.3.
PHP Version
8.2.0
Additional enviornment details
Gutenberg disabled, Classic Editor Plugin installed, Version: 1.6.3
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.






