I'm having trouble sourcing images from Sanity using the new gatsby-plugin-image
. The documentation says to do the following:
import React from 'react'
import {getGatsbyImageData} from 'gatsby-source-sanity'
import {GatsbyImage} from 'gatsby-plugin-image'
const Person = ({data}) => {
const imageData = getGatsbyImageData(data.sanityPerson.profileImage.asset)
return <GatsbyImage image={imageData}/>
}
export default Person
export const query = graphql`
query PersonQuery {
sanityPerson {
profileImage {
asset
}
}
}
`
However when I try and query the image asset, I get the following error:
My query looks like this:
export const query = graphql`
query MyQuery {
allSanityAbout {
nodes {
about_text
about_image {
alt
image {
asset
}
}
}
}
}
`;
The docs also say that "Any GraphQL File object that includes an image will have a childImageSharp
field" but I can't work out how to query for it:
Here are the fields available inside the image
node:
I get errors telling me Cannot query field "childImageSharp"
on fields SanityImage
or SanityImageAsset
if I try and query for childImageSharp
on the image
or asset
nodes.
Any pointers greatly appreciated!
image
node?