【发布时间】:2020-12-08 03:55:09
【问题描述】:
对于我选择的任何 childimagesharp 变体,我收到此错误“无法在类型“StrapiHomesGalleryImageFormatsMedium”上查询字段“childImageSharp”,即使它们可以在左侧菜单中选择。我无法弄清楚为什么它在何时不可查询其他一切正常。Galleryimage 是一组图像。
应用代码 -
import React from "react"
import { graphql, Link } from "gatsby"
import Image from "gatsby-image"
import ImageGallery from 'react-image-gallery';
const ComponentName = ({ data }) => {
const {id, galleryImage} = data.home
console.log('data is', data)
const images = [];
return (
<Layout>
<section className="template">
<ImageGallery items={images} />;
</section>
</Layout>
)
}
export const query = graphql`
query GetSingleHome($slug: String) {
home: strapiHomes(slug: { eq: $slug }) {
galleryImage {
formats {
large {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
id
}
}
small {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
id
}
}
}
}
MainImage {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
}
}
`
【问题讨论】: