gridsome / gridsome/gridsome-starter-wordpress

TypeError: Cannot read property 'addReference' of undefined

Open
#4 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vue
Stars
92
Forks
30
PR merge metrics
No merged PRs in 30d

Description

(Originally posted this on [gridsome](https://github.com/gridsome/gridsome/issues/47), 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`:

```bash
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
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:

```javascript
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`:

```javascript

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.