I am working on a Gatsby site and sourcing my content from Sanity.io. Some of the images I am getting back from the Sanity.io CDN are of a significantly reduced quality when compared to images that I source through my own file system. I think it has something to do with an incorrect image size being set but I cannot figure out why it is setting this image incorrectly. I am attempting to render both of these elements using gatsby-image.
A screenshot of the images loaded next to each other:
My graphQL query:
const HEADER_QUERY = graphql`
query HeaderQuery {
HeaderImages: sanityHomepageSettings {
heroOverlayImage {
asset {
fluid(maxWidth: 300) {
...GatsbySanityImageFluid
}
}
}
}
LocalHeaderImages: file(relativePath: {eq: "happy.png"}) {
childImageSharp {
fluid(maxWidth: 300) {
...GatsbyImageSharpFluid
}
}
}
}
`
Where I am rendering both of these images:
<div style={{backgroundColor: 'white', width: '100%'}}>
<Img fluid={data.HeaderImages.heroOverlayImage.asset.fluid} />
<Img fluid={data.LocalHeaderImages.childImageSharp.fluid} />
</div>
When I inspect the image elements in my devtools I can see that the currentSrc for the image coming from sanity is as follows:
https://cdn.sanity.io/images/<environment-removed>/production/<long-name-removed>-275x132.png?w=150&h=72&fit=crop&fm=webp
It looks like an improperly sized image is being set here because the width and height are ~50% of the original image. As you can see from the string above, w=150&h=72 appear to be sizing the image.
Lastly, I am getting the following warning in my console when starting up my Gatsby environment:
warn: The type `SanityImageAsset` does not explicitly define the field `childImageSharp`. On types with the `@dontInfer` directive, or with the `infer` extension set to `false`, automatically
Is there something a did incorrectly here or is there something I am missing as part of my setup? As a note, I have purged and reinstalled my node modules, public, and cache folders.