gatsbyjs / gatsby-source-wordpress-experimental

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

Custom fields on pageInfo #387

Closed ashhitch closed 3 years ago

ashhitch commented 3 years ago

In my Yoast plugin, I have some custom fields that get added to the pageInfo object, however, they do not come through to the source plugin. Is there a way to make this work?

Here is an example query in WpGraphQL

query MyQuery {
  posts {
    pageInfo {
      seo {
        schema {
          raw
        }
      }
    }
    nodes {
      title
    }
  }
}

For context here is the code in the plugin https://github.com/ashhitch/wp-graphql-yoast-seo/blob/master/wp-graphql-yoast-seo.php#L822

TylerBarnes commented 3 years ago

Hi @ashhitch the source plugin only pulls in data that's attached to individual nodes or non-node root fields. Any edge data between root node list fields and the node data isn't picked up as it doesn't translate to the Gatsby node model. If these fields were node-data on a ContentType node it would be picked up:

{
  contentTypes {
    nodes {
      name
      # seo {
      #   schema {
      #     raw
      #   }
      # }
    }
  }
}
{
  "data": {
    "contentTypes": {
      "nodes": [
        {
          "name": "post"
        },
        {
          "name": "page"
        },
        {
          "name": "attachment"
        },
        {
          "name": "action_monitor"
        }
      ]
    }
  },
}

Unfortunately there isn't a way to make this work in this source plugin. Sorry about that!