Reputation: 5510
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?
Upvotes: 1
Views: 631
Reputation: 5510
It turns out what I needed here existed within the domain of the standard wp rest-api endpoint /wp-json/wp/v2/tags
. The query that worked was:
query {
allWordpressTag {
nodes {
id
name
}
}
}
Upvotes: 1