gatsby-source-wordpress yoast SEO not pulling posts `content vs content___NODE`

Created on 16 Oct 2019  路  1Comment  路  Source: gatsbyjs/gatsby

Summary

I am trying to pull yoast info using this plugin https://wordpress.org/plugins/wp-rest-yoast-meta/

Relevant information

The plugin adds rest endpoints to give each post and page object a yoast_meta object. That gatsby gathers.

This works perfectly on pages.
On posts of any post type I get nothing but an empty object.

If i examine the wordpress post endpoint I can see the yoast_meta object containing the correct info.

I am getting a warning which I believe is the issue.

warn Multiple node fields resolve to the same GraphQL field `wordpress__POST.yoast_meta.content` - [`content`, `content___NODE`]. Gatsby will use `content___NODE`.
warn Multiple node fields resolve to the same GraphQL field `wordpress__wp_media.yoast_meta.content` - [`content`, `content___NODE`]. Gatsby will use `content___NODE`.
warn Multiple node fields resolve to the same GraphQL field `wordpress__wp_insights.yoast_meta.content` - [`content`, `content___NODE`]. Gatsby will use `content___NODE`.
warn Multiple node fields resolve to the same GraphQL field `wordpress__wp_work.yoast_meta.content` - [`content`, `content___NODE`]. Gatsby will use `content___NODE`.

Does any one know how to set gatsby to use "content" over "content___NODE" for these instances.

Environment (if relevant)

System:
OS: macOS 10.14.2
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.16.3 - /var/folders/h2/tc6gfgs51c99bsrdxzhgf4lw0000gp/T/yarn--1571245290530-0.8037819346931683/node
Yarn: 1.13.0 - /var/folders/h2/tc6gfgs51c99bsrdxzhgf4lw0000gp/T/yarn--1571245290530-0.8037819346931683/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 77.0.3865.120
Firefox: 68.0.2
Safari: 12.0.2
npmPackages:
gatsby: ^2.1.18 => 2.7.5
gatsby-awesome-pagination: ^0.3.3 => 0.3.4
gatsby-plugin-catch-links: ^2.0.13 => 2.0.15
gatsby-plugin-google-tagmanager: ^2.1.5 => 2.1.5
gatsby-plugin-lodash: ^3.0.4 => 3.0.5
gatsby-plugin-netlify: ^2.0.11 => 2.0.17
gatsby-plugin-purgecss: ^4.0.0 => 4.0.0
gatsby-plugin-react-helmet: ^3.0.7 => 3.0.12
gatsby-plugin-sass: ^2.0.10 => 2.0.11
gatsby-plugin-sharp: ^2.0.22 => 2.1.2
gatsby-remark-images: ^3.0.5 => 3.0.14
gatsby-source-filesystem: ^2.0.23 => 2.0.37
gatsby-source-wordpress: ^3.0.40 => 3.0.62
gatsby-transformer-remark: ^2.3.0 => 2.3.12
gatsby-transformer-sharp: ^2.1.14 => 2.1.20

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

Most helpful comment

Try adding following to gatsby-node.js file (you might need to update your gatsby version, but try it first with one you currently use):

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions
  const typeDefs = `
    type WordpressYoastMeta @dontInfer {
      property: String
      content: String
    }

    type wordpress__POST implements Node @infer {
      yoast_meta: [WordpressYoastMeta]
    }
  `
  createTypes(typeDefs)
}

If it will fix the issue for wordpress__POST type, repeat setting yoast_meta field for wordpress__wp_media, wordpress__wp_insights and wordpress__wp_work

>All comments

Try adding following to gatsby-node.js file (you might need to update your gatsby version, but try it first with one you currently use):

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions
  const typeDefs = `
    type WordpressYoastMeta @dontInfer {
      property: String
      content: String
    }

    type wordpress__POST implements Node @infer {
      yoast_meta: [WordpressYoastMeta]
    }
  `
  createTypes(typeDefs)
}

If it will fix the issue for wordpress__POST type, repeat setting yoast_meta field for wordpress__wp_media, wordpress__wp_insights and wordpress__wp_work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3CordGuy picture 3CordGuy  路  3Comments

signalwerk picture signalwerk  路  3Comments

rossPatton picture rossPatton  路  3Comments

benstr picture benstr  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments