pristas-peter / wp-graphql-gutenberg-acf

Expose acf blocks through graphql
MIT License
62 stars 29 forks source link

Example #2

Closed CHEWX closed 5 years ago

CHEWX commented 5 years ago

Hi,

Do you have an example of querying Advanced Custom Fields?

Thanks, Tom

pristas-peter commented 5 years ago

Hi, here you gi, however there is an issue with acf pro, that needs to be sorted out. https://github.com/AdvancedCustomFields/acf/issues/192

{
  pages(where: {name: "index"}) {
    edges {
      node {
        id
        blocks {
          ...on AcfBannerCarouselBlock {
            acf {
              items {
                image {
                  status
                }
                link {
                  title
                }
              }
            }
          }
        }
      }
    }
  }
}

If you need to know the name of AcfBannerCarouselBlock, just open GraphiQL and type Acf in the search box in the documentation tab. Since all ACF block type names are prefixed with 'Acf' , it should list all of them.

CHEWX commented 5 years ago

Ok, be good to get that into a README.

So I assume everything will return blank/null currently? As this is what I am getting?

pristas-peter commented 5 years ago

I guess. Try to put multiple acf blocks into the content and if you edit only one of them, the other should work. I have a sort of fix for this, but want to fix it on the acf pro side, not mine.

pristas-peter commented 5 years ago

Fixed in #3