Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Bug in gatsby-plugin-graphql-codegen@2.7.0 when used with graphql@15.0.0 #82

Open
kaleabmelkie opened this issue Apr 4, 2020 · 5 comments

Comments

@kaleabmelkie
Copy link

kaleabmelkie commented Apr 4, 2020

Emits error:

AggregateError: GraphQLDocumentError: Fragment "GatsbyImageSharpFixed" is never used.

Here is the full log.

In case it helps, these are the versions of some of the potentially related dependencies I'm using:

{
    "apollo-boost": "^0.4.7",
    "gatsby": "^2.20.12",
    "gatsby-image": "^2.3.1",
    "gatsby-plugin-graphql-codegen": "^2.7.0",
    "gatsby-plugin-sharp": "^2.5.3",
    "gatsby-plugin-typescript": "^2.3.1",
    "gatsby-plugin-typescript-checker": "^1.1.1",
    "gatsby-transformer-sharp": "^2.4.3",
    "graphql": "^15.0.0",
    "graphql-cli": "^3.0.14",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "typescript": "^3.8.3"
}

UPDATE:

The problem appears when used with graphql@15.0.0. It works fine with graphql v14.6.0.

@kaleabmelkie kaleabmelkie changed the title Bug in gatsby-plugin-graphql-codegen@2.7.0 when used with gatsby-image and sharp Bug in gatsby-plugin-graphql-codegen@2.7.0 when used with graphql@15.0.0 Apr 4, 2020
@d4rekanguok
Copy link
Owner

Ooh very interesting, thank you for opening an issue! I'll try to fix this

@d4rekanguok
Copy link
Owner

Hey @kaleabmelkie, I was unable to reproduce this error. Do you have a sample project I can use? It seems like latest version of Gatsby has yet to use graphql 15 & when I force with yarn resolution, it just choked. I must have missing something.

Nevertheless I've upgraded all our dependencies to supports graphql 15, would you give it a try to see if it fixes the error? (gatsby-plugin-graphql-codegen@2.7.1)

@kaleabmelkie
Copy link
Author

With v2.7.1 (and graphql@15.0.0) it logs a similar (but smaller) error on the console, but it actually launches the app and it works fine.

Here is a sample project:

https://codesandbox.io/s/frosty-neumann-uou9z

(Fork and restart it, if you want to see the error on console)

@d4rekanguok
Copy link
Owner

Thanks, that's solid! I've found this error:

failed We've encountered an error: Objects are not valid as
a React child
(found: GraphQLDocumentError: GraphQLDocumentError: Fragment
"GatsbyImageSharpFixed" is never used.). If you meant to render a collection of
children, use an array instead.

Will go from there

@d4rekanguok
Copy link
Owner

Hey @kaleabmelkie, thank you again for providing a reproduction!

I think it boils down to incompatible issue with the graphql version Gatsby uses — I'm not sure what we can do here until Gatsby upgrades to graphql 15 :(.

If you happen to use yarn, pinning Gatsby's graphql version to 14.6 seem to resolve the issue:

in package.json

{
  "resolutions": {
    "gatsby/graphql": "14.6.0"
  }
}

Though yarn resolution seems to be a little flaky. I fount it to work more consistently if I nuke node_modules and run yarn again after specifying new resolutions.

Hope it helps — I'll keep this issue open.

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

No branches or pull requests

2 participants