gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.22k stars 10.32k forks source link

WordPressAcf_post_photo causing errors in latest "WordPress example" #6231

Closed markedup closed 6 years ago

markedup commented 6 years ago

Description

Cannot successfully build using a wordpress.com-hosted site in the latest (i.e. 'Next') version of the example-wordpress demonstration.

Steps to reproduce

  1. Download latest version of example-wordpress
  2. Execute npm install in Terminal
  3. Add relevant WordPress 'My Apps' auth credentials to gatsby-config.js [full code below]
  4. Execute npm run build in Terminal

Expected result

A static version of your hosted WordPress site is output to the local file system.

Actual result

error GraphQL Error Unknown type "WordPressAcf_post_photo". Did you mean [...]

  file: /Users/petef/Development/gatsby-using-wordpress/src/templates/post.js

  1 |
  2 |   query currentPostQuery($id: String!) {
  3 |     wordpressPost(id: { eq: $id }) {
  4 |       title
  5 |       content
  6 |       ...PostIcons
  7 |       acf {
  8 |         page_builder_post {
  9 |           __typename
> 10 |           ... on WordPressAcf_post_photo {
    |                  ^
  11 |             photo {
  12 |               localFile {
  13 |                 childImageSharp {
  14 |                   fluid(maxWidth: 680) {
  15 |                     ...GatsbyImageSharpFluid
  16 |                   }
  17 |                 }
  18 |               }
  19 |             }
  20 |           }

Environment

System:
  OS: macOS High Sierra 10.13.5
  CPU: x64 Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz
  Shell: 5.3 - /bin/zsh
Binaries:
  Node: 10.0.0 - ~/.nvm/versions/node/v10.0.0/bin/node
  npm: 6.1.0 - ~/.nvm/versions/node/v10.0.0/bin/npm
Browsers:
  Chrome: 67.0.3396.99
  Safari: 11.1.1
npmPackages:
  gatsby: next => 2.0.0-beta.13
  gatsby-image: next => 2.0.0-beta.3
  gatsby-plugin-glamor: next => 2.0.0-beta.2
  gatsby-plugin-react-helmet: next => 3.0.0-beta.3
  gatsby-plugin-sharp: next => 2.0.0-beta.2
  gatsby-plugin-typography: next => 2.2.0-beta.2
  gatsby-source-wordpress: next => 3.0.0-beta.4
  gatsby-transformer-sharp: next => 2.1.1-beta.3
npmGlobalPackages:
  gatsby-cli: 1.1.58

File contents (if changed)

gatsby-config.js

module.exports = {
  siteMetadata: {
    title: `A sample site using gatsby-source-wordpress`,
    subtitle: `Data fetched from a site hosted on wordpress.com`
  },
  plugins: [
    {
      resolve: `gatsby-source-wordpress`,
      options: {
        baseUrl: `BASE_URL.wordpress.com`,
        protocol: `http`,
        hostingWPCOM: true,
        auth: {
          wpcom_app_clientSecret: "CLIENT_SECRET",
          wpcom_app_clientId: "CLIENT_ID",
          wpcom_user: "USER_EMAIL",
          wpcom_pass: "USER_PASSWORD"
        },
        useACF: false
      }
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    `gatsby-plugin-glamor`,
    {
      resolve: `gatsby-plugin-typography`,
      options: {
        pathToConfigModule: `src/utils/typography.js`
      }
    }
  ]
};

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

pieh commented 6 years ago

using-wordpress example is specifically adjusted to demo things that vanilla wordpress installation won't include - this particular error - ACF Flexible Content field. So this is to be expected that exapmle won't work with other urls. If you are looking to start testing I think using something like https://github.com/ericwindmill/gatsby-starter-wordpress should work

markedup commented 6 years ago

Feels misleading to have the useACF field toggle in there then, but thanks for the link to the starter project all the same.

pieh commented 6 years ago

That example does use acf, so it need to have useACF. But that said we could add disclaimer somewhere that using-wordpress is tied to specific wordpress instance and won't work with other instances - would You be interested in creating PR for this?