wp-graphql / wpgraphql-acf

Re-architecture of WPGraphQL for ACF
GNU General Public License v3.0
91 stars 12 forks source link

Field group is not displayed in GraphQL if individual pages are excluded #206

Closed stefanmomm closed 5 months ago

stefanmomm commented 6 months ago

Description

I have created a new field group that is displayed on all pages, but I want to exclude a specific page. I have activated "Show in GraphQL", but it is not displayed in GraphQL for any page (not only the excluded one). Only when I remove the second rule (the excluded page) is it displayed correctly. If I add the rule again, the field group disappears from GraphQL again.

Bildschirmfoto 2024-05-24 um 10 45 45

Steps to reproduce

  1. Add a new field group and make sure "Show in GraphQL" is activated
  2. Add a rule "Post Type is equal to Page"
  3. Check if field group is displayed in GraphQL
  4. Add another AND rule "Page is not equal to [Name of any page]"
  5. Check if field group is displayed in GraphQL

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

No response

Additional context

No response

WPGraphQL Version

1.26.0

WPGraphQL For ACF Version

2.2.0

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

6.3.0.1 (Pro)

WordPress Version

6.5.3

PHP Version

8.2.18

Additional enviornment details

No response

Please confirm that you have searched existing issues in the repo.

Please confirm that you have disabled ALL plugins except for WPGraphQL, WPGraphQL For ACF, ACF, etc.

jasonbahl commented 5 months ago

@stefanmomm thanks for opening an issue and providing details about your scenario.

While WPGraphQL for ACF does attempt to automatically map ACF Field Groups to the Schema based on location rules, some rules are difficult to interpret and are not mapped automatically.

Your location rules fall into that category.

When you set a location rule to be something and also not that same thing (i.e. pages, but not one specific page) then the auto mapping isn't sure how to apply the rule.

In these cases, you will need to manually map the ACF Field Group to the schema using the "Manually Set GraphQL Types for Field Group"

You can read more about this here: https://acf.wpgraphql.com/adding-acf-fields-to-the-wpgraphql-schema/#acf-field-group-location-rules