Home:ALL Converter>How to get list of ACF taxonomy value options in gatsby-source-wordpress

How to get list of ACF taxonomy value options in gatsby-source-wordpress

Ask Time:2019-06-27T08:43:40         Author:fraxture

Json Formatter

I'm using the gatsby-source-wordpress plugin with gatsby to pull data from a wordpress cms. I'm also using ACF fields in Wordpress and have install the acf-to-rest-api plugin. With this plugin installed gatsby-source-wordpress plugin is able to pull ACF field data.

My question is: how can I get a list of taxonomy value options from a certain field? I don't want the taxonomy items associated with the particular post types in question, but a list of possible options.

To be a bit more specific, this query:

query MyQuery {
  allWordpressAcfResource {
    nodes {
      acf {
        topics {
          name
        }
      }
    }
  }
}

returns data like:

{
  "data": {
    "allWordpressAcfResource": {
      "nodes": [
        {
          "acf": {
            "topics": [
              {
                "name": "Germany"
              },
              {
                "name": "United States"
              },
            ]
          }
        },
        {
          "acf": {
            "topics": [
              {
                "name": "Dogs"
              },
              {
                "name": "Germany"
              }
            ]
          }
        },
        ...
        ...
        ...

What I want is to get a list from the above that would just hold the possibly taxonomy values, but I have been unable to discover a GraphQL query to do this.

Does anyone know if this is possible?

Author:fraxture,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/56782566/how-to-get-list-of-acf-taxonomy-value-options-in-gatsby-source-wordpress
yy