contentstack / gatsby-source-contentstack

Contentstack provides a source plugin for pulling content into Gatsby from Contentstack stacks. It helps you query content types and entries in Gatsby using GraphQL
MIT License
14 stars 31 forks source link

Gatsby plugin image required #127

Open psykzz opened 2 years ago

psykzz commented 2 years ago

With PR #123 (https://github.com/contentstack/gatsby-source-contentstack/pull/123/files#diff-6d7a97f0e776f3de4a5359346231cd4ce6b76c437f8a414cecf918f23dfe9e62R45-R49) there is a new requirement for users to install additional plugins, even if they were not using those features. This change was published as a patch version 3.1.1.

While i really appreciate the support to add these new features, having a patch upgrade fail builds and require new plugins feel bad.

Instead of a panic, could the feature just return the empty object. (Similar to if its not an asset originally).

Context error message

11:37:56  error Gatsby plugin image is required. Please check https://github.com/contentstack/gatsby-source-contentstack#the-new-gatsby-image-plugin for more help.
11:37:56  
11:37:56  
11:37:56    Error: Cannot find module 'gatsby-plugin-image/graphql-utils'
11:37:56    Require stack:
11:37:56    - /home/jenkins/workspace/node_modules/gatsby-source-contentstack/extend-node-type.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby-source-contentstack/gatsby-node.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/bootstrap/load-plugins/load.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/bootstrap/load-plugins/index.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/bootstrap/load-config-and-plugins.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/services/initialize.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/services/index.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/bootstrap/index.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/commands/build.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/dist/bin/gatsby.js
11:37:56    - /home/jenkins/workspace/node_modules/gatsby/cli.js
vkalta commented 2 years ago

@psykzz That's a brilliant suggestion. We will address this ASAP. Thanks.

vkalta commented 2 years ago

@psykzz We have fixed this issue with release of v3.1.2. Please check and confirm.

emilyfoxmusic commented 2 years ago

I think I'm having the same/a related issue with v4.0.1.

When I run npm start I get:

Missing onError handler for invocation 'building-schema', error was 'Error: Type with name "GatsbyImageLayout" does not exists'. Stacktrace was 'Error: Type with name "GatsbyImageLayout" does not exists
    at SchemaComposer.get (C:\...\node_modules\graphql-compose\src\TypeStorage.ts:39:13)
    at ThunkComposer._thunk (C:\...\node_modules\graphql-compose\src\TypeMapper.ts:737:34)
    at ThunkComposer.get ofType [as ofType] (C:\...\node_modules\graphql-compose\src\ThunkComposer.ts:21:34)
    at getTypeNode (C:\...\node_modules\graphql-compose\src\utils\definitionNode.ts:253:28)
    at getTypeNode (C:\...\node_modules\graphql-compose\src\utils\definitionNode.ts:253:12)
    at C:\...\node_modules\graphql-compose\src\utils\definitionNode.ts:286:20
    at Array.map (<anonymous>)
    at getArgumentsDefinitionNodes (C:\...\node_modules\graphql-compose\src\utils\definitionNode.ts:284:6)
    at C:\...\node_modules\graphql-compose\src\utils\definitionNode.ts:320:20
    at Array.map (<anonymous>)
    at getFieldDefinitionNodes (C:\...\node_modules\graphql-compose\src\utils\definitionNode.ts:312:6)
    at getObjectTypeDefinitionNode (C:\...\node_modules\graphql-compose\src\utils\definitionNode.ts:61:13)
    at ObjectTypeComposer.getType (C:\...\node_modules\graphql-compose\src\ObjectTypeComposer.ts:986:57)
    at getGraphQLType (C:\...\node_modules\graphql-compose\src\utils\typeHelpers.ts:308:17)
    at C:\...\node_modules\graphql-compose\src\SchemaComposer.ts:227:47
    at Array.forEach (<anonymous>)'

I added gatsby-plugin-image to my dependencies and gatsby-config.js and the error disappeared.

So I don't think the dependency has been properly removed yet?

vkalta commented 2 years ago

@emilyfoxmusic Let me check and get back to you.

vkalta commented 2 years ago

@emilyfoxmusic I just re-checked this with version 4.0.1 and 4.0.2. I did not encounter this issue. Can you please share more details in order to reproduce this?

Thanks

emilyfoxmusic commented 2 years ago

@vkalta ah interesting, thanks for checking. I will try and collect more info tomorrow when I'm back at my laptop then. I think I did also notice that in v4.0.1 gatsby-plugin-image was still listed as a peer dependency in the package lock? But I will check everything tomorrow and see if I can get some reproducible results, and dig a bit more in case it's related to another change I made. Much appreciated, thanks!

emilyfoxmusic commented 2 years ago

@vkalta I just gave this another look and I can confirm that when I remove gatsby-source-contentstack it will build correctly (albeit fail at runtime as would be expected!), so it does seem it it this package causing the issue? Also, I note that gatsby-plugin-image is definitely listed as a peer dependency - is that incorrect now?

What further information do you think would help to debug this? I could just add this package as a dependency, but I'd rather not if possible. I am on node v16.13.0, Gatsby v4.10.3 and this plugin is v4.0.1.

Let me know if you'd like me to open a separate issue.

vkalta commented 2 years ago

@emilyfoxmusic Which OS are you using?

emilyfoxmusic commented 2 years ago

@vkalta Windows 10

vkalta commented 2 years ago

Thanks @emilyfoxmusic. We are checking this issue on windows 10, and will get back to you asap.