craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

Error while running the createResolvers lifecycle #18

Closed ken-gladeye closed 3 years ago

ken-gladeye commented 3 years ago

Description

I got the error when running either gatsby develop or gatsby build

"gatsby-source-craft" threw an error while running the createResolvers lifecycle:

Cannot read property 'name' of undefined

  382 |     const ifaceName = loadedPluginOptions.typePrefix + 'AssetInterface';
  383 |     const iface = intermediateSchema.getType(ifaceName);
> 384 |     const possibleTypes = intermediateSchema.getPossibleTypes(iface);
      |                                              ^
  385 |     const resolvers = {};
  386 |     for (const assetType of possibleTypes) {
  387 |         resolvers[assetType] = {

Steps to reproduce

  1. Install and configure the plugin as per the doc
    {
    resolve: `gatsby-source-craft`,
    options: {},
    },
  2. Either run gatsby develop or gatsby build

Additional info

ken-gladeye commented 3 years ago

Okay, so the workaround is setup a dummy asset volume and enable it in the graphql schema, then the error goes away.

andris-sevcenko commented 3 years ago

@ken-gladeye it's still a bug, though. It's on my list to fix this, but thank you for sharing a workaround!

andris-sevcenko commented 3 years ago

Alright, just fixed this for the next release. Thanks for reporting!

ken-gladeye commented 3 years ago

Awesome, thank you!