wp-graphql: How do I get data from custom post types?

783 Views Asked by At

I'm experimenting with Gatsby.

On the WordPress side I've installed the plugin wp-graphql. (I've also installed wp-graphql-acf, because I've got some ACF fields that I want to expose )

I have two CPT's. For both of the CPT's I've passed the following parameters in the register_post_type array:

'show_in_rest'         => true,
'show_in_graphql'      => true,
'graphql_single_name'  => 'album',
'graphql_plural_name'  => 'albums'

I then start 'gatsby develop' and go to the graphiql interface to start looking for data.

In the Explorer I can a toggle with the title allWpAlbum

So: the cpt exists. It is exposed to graphiql. Instances of the CPT exist and are published.

However, I can't figure out to get any actual data. Queries like the following one return empty sets:

query MyQuery {
  allWpAlbum {
    edges {
      node {
        id
      }
    }
  }
 
}

So: how do I actually the posts?

0

There are 0 best solutions below