DEV Community

An Introduction To Using Gatsby Image & Gatsby.js V2

Hunter Chang on September 20, 2018

This post was originally published at codebushi.com For a video tutorial, check out https://www.youtube.com/watch?v=kOrohVsq_kI Gatsby.js V2 was...
Collapse
 
jpm1118 profile image
Jack McCormick

Excellent tutorial Hunter! Quick question, if you don't mind. Why does the pageQuery const need to be exported? Is this simply how Gatsby-image accesses the query? Thanks!

Collapse
 
changoman profile image
Hunter Chang

Yes, that's how the component is able to consume the GraphQL query. I think it needs to be exported because that's how Gatsby is able to process it during the build. Check out this page for more info: gatsbyjs.org/docs/page-query

Collapse
 
mcborreo profile image
Caye

Hallo, thank you so much for this helpful guide! The DRY code at the end was a gem. If you don't mind asking me though, would you happen to know how to test a component that uses gatsby-image?

Collapse
 
twiloportium profile image
george.yiangou@me.com

This is a good learning curve to get going with graphql and gatsby-image. Nicely structured.