Gatsby-source-ghost plugin not functioning correctly

I have been trying to use the “gatsby-source-ghost” plugin for Gatsby to display posts from the blog, but I am seeing an error as soon as I add the setup to my gatsby-config.js file. Just to clarify, I added per instructions, like this:

{
  resolve: 'gatsby-source-ghost',
  options: {
    apiUrl: 'http://mydomain.com/ghost',
    contentApiKey: 'xxx',
  },
},

I have posts live and see lots of posts in the JSON response when I manually hit the v2 API, so not sure why I get an error here…

I am using version: 4.01 (latest) and the error details are:

ERROR #11321 PLUGIN
“gatsby-source-ghost” threw an error while running the sourceNodes lifecycle:
Cannot read property ‘map’ of undefined
TypeError: Cannot read property ‘map’ of undefined

  • gatsby-node.js:31 transformCodeinjection
    [landing-page]/[gatsby-source-ghost]/gatsby-node.js:31:11

  • gatsby-node.js:71
    [landing-page]/[gatsby-source-ghost]/gatsby-node.js:71:17

  • task_queues.js:89 processTicksAndRejections
    internal/process/task_queues.js:89:5

  • From previous event:

  • gatsby-node.js:120 createLiveGhostNodes
    [landing-page]/[gatsby-source-ghost]/gatsby-node.js:120:20

  • gatsby-node.js:155 Object.exports.sourceNodes
    [landing-page]/[gatsby-source-ghost]/gatsby-node.js:155:12

  • api-runner-node.js:234 runAPI
    [landing-page]/[gatsby]/dist/utils/api-runner-node.js:234:37

  • api-runner-node.js:347 Promise.catch.decorateEvent.pluginName
    [landing-page]/[gatsby]/dist/utils/api-runner-node.js:347:15

  • api-runner-node.js:346
    [landing-page]/[gatsby]/dist/utils/api-runner-node.js:346:12

  • timers.js:439 processImmediate
    internal/timers.js:439:21

Any help appreciated!

Hey @Oli_C

Your Ghost instance is probably not upgraded to 3.0 yet, but the source plugin defaults to 3.0, see here:
GitHub - TryGhost/gatsby-source-ghost: Source plugin for pulling data into Gatsby.js from the Ghost Public API.

You will either need to upgrade your Ghost install, or pass in the version property, set to v2.

Let me know if that solved the issue.

Thanks Aileen, I tried changing the version to v2, but it also fails, so I have left an issue on the Github page.