gatsbyjs/gatsby-source-wordpress-experimental

Custom fields on pageInfo

Closed this issue · 1 comments

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

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!