Skip to content

ACF fields cannot be queried in previews #154

@andremendonca03

Description

@andremendonca03

Description

It looks like ACF fields cannot be queried in previews (at least not the preview data).
My Goal: Be able to access ACF preview data from the API.

This is my query:

query MyQuery2 {
  post(id: 125, idType: DATABASE_ID, asPreview: true) {
    title
    skeleton {
      textField
      skeleton {
        ... on SkeletonSkeletonHeadingCopyLayout {
          title
        }
      }
    }
  }
}

The post's title gets the preview value correctly but both ACF fields are returned with their published values (not the preview).

I've also already tried many variations of this query using revisionOf, or with asPreview: false and accessing by {preview {...}}, or even querying using nodeByUri. Never works.

Screenshot 2024-01-05 at 8 52 22 am (1)

Steps to reproduce

  1. I am using WordPress 6.4.2 currently on a localhost from Local by Flywheel PHP version 8.2.8.
  2. Deactivated all plugins except: WPGraphQL, ACF Pro and WPGraphQL for ACF to avoid any possible plugin conflict.
  3. Installed the Twenty Twenty Four theme to avoid any possible theme conflict.
  4. The only modification to the original theme was to add a filter: add_filter('use_block_editor_for_post_type', '__return_false', 10); to remove gutenberg editor.
  5. Create a new Field Group active in GraphQL with one normal text field and one flexible content field with a text field inside.
  6. Added the Field Group to pages and posts.
  7. Created a new post, updated content and then clicked on "Preview changes" button.
  8. Used the query to view preview content but only the Post's title had a correct preview data. ACF field were still retrieving the published data.

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

acf-export-2024-01-16.json

Additional context

No response

WPGraphQL Version

1.19.0

WPGraphQL For ACF Version

2.0.0 (download from WP plugin not github)

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

6.2.5 PRO

WordPress Version

6.4.2

PHP Version

8.2.8

Additional enviornment details

No response

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions