Date

WPGraphQL for ACF v3.1.0

WPGraphQL for ACF 3.1.0 is out!

It’s the biggest WPGraphQL for ACF release in a while. It includes one new feature and more than a dozen bug fixes, several of them long-standing issues reported by the community.

A few of those fixes change what some queries return, so please read what to check before updating before you update a production site.

Secure Custom Fields is supported

Secure Custom Fields (SCF), the WordPress.org fork of Advanced Custom Fields, is now “officially” supported. WPGraphQL for ACF already worked with SCF, but we didn’t have test suites to “prove” it, so we couldn’t call it supported. The full test suite now runs against SCF on every pull request, alongside ACF and ACF PRO. See Installation and activation for details.

Fields inside repeaters and flexible content

Several field types worked at the top level of a field group but came back empty inside repeater and flexible content rows. They now resolve the same way everywhere:

  • Page Link fields, and Image, File and Gallery fields set to the URL return format, returned null (or an empty list for galleries).
  • Link fields set to the “Link URL” return format returned null.
  • Date Picker and Date Time Picker fields could resolve as 1970-01-01, or with the day and month swapped, when their return format used slashes (such as d/m/Y).

Other fixes

  • Location rules that exclude types. Field groups using “is not equal to” location rules now leave the types those rules exclude, and “Block is equal to All” now adds a field group to every ACF block type.
  • WYSIWYG fields. Values are no longer run through WordPress’s the_content filter, so markup other plugins add to post content (sharing buttons, related posts) no longer shows up in WYSIWYG fields. Block markup in a WYSIWYG field is now rendered the way the_content renders it, without stray paragraph tags.
  • Zero values. Number, range, text, select and checkbox fields that store 0 now return 0 instead of null.
  • Date Time Picker seconds. Date Time Picker fields return the stored seconds instead of 00.
  • “Both (Array)” select fields. A single-value select set to “Both (Array)” returns just the value, the same as a multi-value select.
  • fieldGroupName is no longer deprecated, which fixes schema builds in tools like Gatsby that leave deprecated fields out.
  • Field groups on ACF before 6.1 keep their key and GraphQL settings when saved.
  • In the admin, opening a field group no longer prompts “Leave site?” when nothing changed, and the plugin no longer loads its translations too early, which with WP_DEBUG on could break REST API responses.

The full list is in the 3.1.0 release notes.

What to check before updating

These are bug fixes, but some sites may have built on the old behavior. The upgrade notice in the 3.1.0 release notes covers each one in detail. In short:

  • Field groups with “is not equal to” location rules were showing up on the types they exclude, and now don’t, so fields may disappear from those types. To keep a field group on a type its rules exclude, turn on “Manually Set GraphQL Types for Field Group” and choose the types yourself. A field group set to “Block is not equal to All” now matches no block, the same as in ACF.
  • WYSIWYG fields no longer include markup added through the_content. If you relied on it, add that callback to ACF’s acf_the_content filter instead. If a client stripped the stray <p> tags around rendered blocks, check it against the new output.
  • Zero values now come back as 0 instead of null, so check any client that treats null as “not set”.
  • Single-value “Both (Array)” selects return ["red"] instead of ["red", "Red"]. If you read the label from the second entry, set the field’s return format to “Label”.
  • Date Time Picker fields now include the stored seconds, and nested dates resolve from the stored date.
  • On ACF older than 6.1, field groups saved before this release may have had their key or GraphQL settings reset. Updating doesn’t repair them, so open your field groups and check their location rules and GraphQL settings.

As always, test the update on a staging site first if you rely on any of these.

Thank you

Thanks to everyone who reported issues, and to the contributors whose pull requests are in this release: @idrewlong, @simonsabin, @wleeaf, @noruzzamans and @pseelinger.

WPGraphQL for ACF now lives in the WPGraphQL monorepo, so that’s the place to report bugs and follow along.