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

ACF Field Groups not showing when set to show on equal page filter #22

Closed
omattman opened this issue Jul 25, 2019 · 8 comments
Closed
Labels
Location Rules Issues related to ACF Location Rules

Comments

@omattman
Copy link

When creating ACF Field Groups and setting the filter for instance as:

Show this field group if:
Page is equal to SELECTED_PAGE

The ACF field isn't queryable through the pageBy with uri. This is the example of the query I ran to find this issue:

{
  pageBy(uri: "live-act") {
    id
    artistCategory {
      category_video
    }
  }
}

Which returns the error:

{
  "errors": [
    {
      "message": "Cannot query field \"artistCategory\" on type \"Page\".",
      "category": "graphql",
      "locations": [
        {
          "line": 4,
          "column": 5
        }
      ]
    }
  ]
}

If one remove the filter and set it to display on all pages it is perfectly queryable in the GraphQL schema.

@omattman
Copy link
Author

omattman commented Jul 26, 2019

Might be a duplicate of #1

@davemcnally
Copy link

I'm struggling with a similar, if not the same issue here — A field group will show up in the schema when location is all pages via post type. However if I add an and condition to rule out a specific page, it's removed entirely, even if just querying a page still allowed to show the field group by that rule.

@jasonbahl jasonbahl added the Location Rules Issues related to ACF Location Rules label Feb 25, 2020
@brianshimkus
Copy link

@omattman @jasonbahl Was a solution found for this?

@omattman
Copy link
Author

omattman commented Apr 4, 2020

@brianshimkus I didn't manage to find a solution. However, I changed my acf for regular pages to act as a page builder (all blocks are available to all post types of "Page"). This way I was able to source all available blocks to the pages that requested a set of the available ACF blocks.

In hindsight, it took a lot of restructuring but engineering wise it is, from my perspective, a way more maintainable and feasible solution as data flows through one controller and dispatches it to the individual pages.

@brianshimkus
Copy link

@omattman Thanks for the quick response. I ended up stripping out all of the wp-graphql plug-ins from my project and instead installed "ACF to REST API" with great success.

@omattman
Copy link
Author

omattman commented Apr 4, 2020

@brianshimkus I started with that plugin, and it works perfectly. I only switched to wp-graphql-acf when it was backed up by the Gatsby team themselves. You will be perfectly fine!

@AbeCole
Copy link

AbeCole commented May 5, 2020

I believe this is similar to an issue I've just resolved, take a look at my pull request #134

@jasonbahl jasonbahl added this to the ACF Schema Location Rules milestone Mar 30, 2021
@jasonbahl
Copy link
Contributor

👋🏻 This has been resolved by v0.5.0 (#250)

The Location Rules have been completely re-worked and you can now set a Field Group to a specific page and it will be applied to the Page type in the Schema.

You can see this in action below:

Screen Shot 2021-04-20 at 3 52 37 PM

This video also walks through the changes: https://www.youtube.com/watch?v=VvrZGrcwv0Y

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Location Rules Issues related to ACF Location Rules
Projects
None yet
Development

No branches or pull requests

5 participants