Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Multiple values Post Object ACF field not working #45

Closed
jasonbahl opened this issue Aug 14, 2019 · 9 comments
Closed

Multiple values Post Object ACF field not working #45

jasonbahl opened this issue Aug 14, 2019 · 9 comments
Labels
bug Something isn't working Field Type: Post Object

Comments

@jasonbahl
Copy link
Contributor

Originally posted here: wp-graphql/wp-graphql#939


When using a multiple values Post Object ACF field, WPGraphQL return an empty object instead of the list of post objects.

Steps to reproduce:

  • Make a multiple values Post Object ACF field
  • Try to query it
@cordial
Copy link

cordial commented Feb 14, 2020

Is anyone looking at this? I'm also having this issue.

@cordial
Copy link

cordial commented Feb 14, 2020

I've actually done a (pretty obvious) workaround in case anyone sees this. Just put a single post object into a repeater. Works fine.

@weareimpulse
Copy link

I have been having the same issue, I have a group of fields exposed to GraphQL, each field in the group is a Post Object field type allowing multiple id's to be stored, when accessing this user meta via GraphQL the query always returns null, at this point I can't change the fields as per @cordial suggested above as we are to far into the dev process to change this, has anybody got round this issue or looking into it as it is blocking further development on this area of the project.

Thanks for your time. Charlie

@ProwlElement
Copy link

im having the same issue i have a repeater field that I want to be able to add multiple "Project" custom post types using Post Object and all I can see is
{ pages { nodes { featuredProjects { projectCards { fieldGroupName } } } } }

expected
{ pages { nodes { featuredProjects { projectCards { project { title image location } } } } } }

This should give me access to the post object and i should be able to use it this way or am I missing something?

Any help appreciated.
Thanks,
S

@ProwlElement
Copy link

@cordial
Copy link

cordial commented Jan 28, 2021

Does using a repeater not work for you or fit your needs? My workaround, described above fixed my issue which looks the same as yours (i couldnt find a way of fixing it the original way that worked).

@ProwlElement
Copy link

I got it working using the above plugin
S

@cordial
Copy link

cordial commented Jan 28, 2021

Ah ok, cool!

@jasonbahl
Copy link
Contributor Author

This has been resolved for quite some time.

To reproduce:

Add ACF Field

I created an ACF Field of the "Post Object" field type, and set it to allow multiple selections

Screen Shot 2021-05-14 at 3 31 17 PM

Edit Post with Field

Then I edited a post with this field on it, selecting multiple post objects

Screen Shot 2021-05-14 at 3 31 51 PM

Query the field

Then I queried the field:

v0.5.2

In WPGraphQL for ACF v0.5.2, I queried like so:

{
  post(id: 2179, idType: DATABASE_ID) {
    id
    databaseId
    postTest {
      multiSelectPostObjectField {
        __typename
        ... on Post {
          id
          title
        }
      }
    }
  }
}

Screen Shot 2021-05-14 at 3 29 52 PM

v0.6.0

The upcoming v0.6.0 (#262) is making some changes to the behavior with the Post Object field type, so it can be queried like so:

{
  post(id: 2179, idType: DATABASE_ID) {
    id
    databaseId
    postTest {
      multiSelectPostObjectField {
        nodes {
          __typename
          id
          databaseId
        }
      }
    }
  }
}

Screen Shot 2021-05-14 at 3 34 04 PM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working Field Type: Post Object
Projects
None yet
Development

No branches or pull requests

5 participants