gatsbyjs / gatsby-source-wordpress-experimental

The upcoming v4 of gatsby-source-wordpress, currently in beta
MIT License
385 stars 100 forks source link

Can't filter or sort child pages using wpChildren #411

Closed jonlow closed 3 years ago

jonlow commented 3 years ago

On pages (or hierarchal post types) you can't filter or sort wpChildren. This is essential for us as we need to be able to display page hierarchy.

image

However in the wordpress admin graphiql UI, we can filter/sort children image

Is this easily fixed, or is there a working alternative to what I'm trying to achieve? Thanks!

TylerBarnes commented 3 years ago

This isn't currently possible. The best way to achieve this is to query top level nodes and filter there. So instead of querying wpPage.wpChildren you would query allWpPage([filter by the parent id]).

In the future, nested field filters will be possible but aren't currently. I'm closing this to consolidate with https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/issues/60 since that chunk of work should be done at the same time