gatsby-plugin-image, getting error: Cannot query field "childImageSharp" on type "ContentfulAssetFile". #30657
-
It works fine with {
file(relativePath: {eq: "shared/glasses-image.png"}) {
childImageSharp {
gatsbyImage(layout: FLUID, maxWidth: 664) {
imageData
}
}
}
} but with this query query allContentfulProductsQuery {
allContentfulProducts {
edges {
node {
mainImage {
childImageSharp {
gatsbyImage(layout: FLUID, maxWidth: 664) {
imageData
}
}
}
}
}
}
} or this part changed to file mainImage {
file {
childImageSharp {
gatsbyImage(layout: FLUID, maxWidth: 664) {
imageData
}
}
}
} it's throwing an error Can I use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hi Alexey,
(see this repo for more context) Can you adapt this query for you case, to something like:
Tell me if I am talking nonsense and I can take another look! Rodney |
Beta Was this translation helpful? Give feedback.
Hi Alexey,
I think you might need to try querying a
localFile
object. For the Gatsby 100 Days of Code challenge with Contentful I had something like this:(see this repo for more context)
Can you adapt this query for you case, to something like: