Skip to content

ACF resolve_post_object_source filter returns incorrect result when empty/null #406

@jacobarriola

Description

@jacobarriola

Describe the bug
If using an ACF Post Object field in a repeater, there are instances where a user may save an empty entry. As is, the current filter assumes all values are non-nullable and thus fetches for a post with no ID. As a result, the first product returns.

To Reproduce
Steps to reproduce the behavior:

  1. Create an ACF repeater field
  2. Create one Post Object sub field
  3. On a page, add 2 repeater items, but only selecting a product for 1 of the fields, leaving the 2nd blank
  4. Save page
  5. Run a GraphQL query for the items

Expected behavior
The query should return an array with two objects: one product + one null

Actual behavior
The query returns an array with two product objects

Screenshots
image

image

Desktop (please complete the following information):

  • WooGraphQL: 0.7
  • WooCommerce: 4.7.1
  • ACF: 5.8.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions