【问题标题】:Image in graphql not have childImageSharpgraphql 中的图像没有 childImageSharp
【发布时间】:2021-10-20 01:37:18
【问题描述】:

我正在使用 strapi 动态提供图像。尝试使用新的 gatsby-plugin-image 但是当我尝试查询我的项目时,文档中给出的示例有所不同,我的查询中没有 childImagesharp。我做错了什么?

例子

query {
 blogPost(id: { eq: $Id }) {
   title
   body
   avatar {
     childImageSharp {
       gatsbyImageData(width: 200)
     }
   }
 }
}

我的查询

query MyQuery {
  allStrapiProjects {
    nodes {
      title
      image {
        formats {
          medium {
            url
          }
        }
      }
    }
  }
}

【问题讨论】:

    标签: gatsby strapi gatsby-image


    【解决方案1】:

    您需要childImageSharplocalFile 节点(保存您的图像数据)来显示图像。

    你应该寻找类似的东西:

    {
      allStrapiProject {
        edges {
          node {
            id
            image {
              publicURL
            }
            multipleImages {
              localFile {
                publicURL
              }
            }
          }
        }
      }
    }
    

    检查localhost:8000/___graphql 的可能节点。

    【讨论】:

      猜你喜欢
      • 2021-11-25
      • 2020-07-18
      • 2021-07-16
      • 1970-01-01
      • 2020-04-01
      • 2017-06-04
      • 2021-07-24
      • 1970-01-01
      • 2021-01-23
      相关资源
      最近更新 更多