Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'addReference' of undefined #4

Open
andrewhl opened this issue Nov 18, 2018 · 0 comments
Open

TypeError: Cannot read property 'addReference' of undefined #4

andrewhl opened this issue Nov 18, 2018 · 0 comments

Comments

@andrewhl
Copy link
Member

(Originally posted this on gridsome, reposting here)

I'm using Gridsome ^0.3.0, and @gridsome/source-wordpress, ^0.1.0, and I'm running into the following error upon running gridsome develop:

TypeError: Cannot read property 'addReference' of undefined
    at WordPressSource.fetchWordPressContent (/Users/andrew/code/SpiralPraxis/marketing/node_modules/@gridsome/source-wordpress/index.js:99:20)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

I've got a vanilla installation. I haven't modified any files except gridsome.config.js, and that only to provide a URL to my wordpress site, which is enabled to serve wp-json endpoints.

Here's my config file:

module.exports = {
  plugins: [{
    use: '@gridsome/source-wordpress',
    options: {
      baseUrl: 'https://mywordpresssite.com', // required
      typeName: 'WordPress', // GraphQL schema name (Optional)
      perPage: 100, // How many posts to load from server per request (Optional)
      concurrent: 10, // How many requests to run simultaneously (Optional)
      routes: {
        post: '/:year/:month/:day/:slug', //adds route for "post" post type (Optional)
        post_tag: '/tag/:slug' // adds route for "post_tag" post type (Optional)
      }
    }
  }]
}

Here's the relevant code from @gridsome/source-wordpress/index.js:

    for (const type in taxonomies) {
      const options = taxonomies[type]
      const typeName = makeTypeName(type)
      const route = routes[type] || `/${options.rest_base}/:slug`

      restBases.taxonomies[type] = options.rest_base

      for (const type of options.types) {
        const postTypeName = makeTypeName(type)
        const collection = getContentType(postTypeName)

        collection.addReference(options.rest_base, { typeName, key: '_id' })
      }

      addContentType({ typeName, route })
    }

Not sure what to do. I can't see anything in the documentation that clarifies this issue. Help would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant