简体   繁体   English

您的 GraphQL 查询中出现错误:无法在“StrapiPropiedadesImagen”类型上查询字段“childImageSharp”

[英]There was an error in your GraphQL query: Cannot query field “childImageSharp” on type “StrapiPropiedadesImagen”

When you want to bring me the image with the graphics query, I get an error当你想用图形查询给我带来图像时,我得到一个错误

Cannot query field "childImageSharp" on type "StrapiPropiedadesImagen".无法在类型“StrapiPropiedadesImagen”上查询字段“childImageSharp”。

And she won't let me bring her.而且她不让我带她。 This is the query that I use to try to bring me the image, the others as description, id, wc, parking, price brings it to me without any problem.这是我用来尝试给我带来图像的查询,其他的作为描述,id,wc,停车,价格给我带来没有任何问题。 But I can't find the problem when trying to bring me the image.但是当我试图给我带来图像时,我找不到问题。

const usePropiedades = () => {const datos = useStaticQuery(graphql`
query {
  allStrapiPropiedades {
    nodes {
      nombre
      descripcion
      id
      wc
      precio
      estacionamiento
      habitaciones
      categorias {
        nombre
      }
      agentes {
        nombre
        Telefono
        email
      }
      imagen {
        sharp: childImageSharp {
          fluid(maxWidth: 600, maxHeight: 400) {
            ...GatsbyImageSharpFluid
          }
        }
      }        
    }
  }
}

` `

And I want to show it here:我想在这里展示它:

const PropiedadPreview = ({propiedad}) => {
const { nombre, descripcion, imagen, wc, estacionamiento, habitaciones, precio } = propiedad;
return (<Card> 
   <Image
    fluid={imagen.sharp.fluid} // Here I try to show
   />
   <Contenido>
   <h3>{nombre}</h3>
       <p className="precio">$ {precio} </p>

       <Iconos
       wc={wc}
       estacionamiento={estacionamiento}
       habitaciones={habitaciones}
       />
   </Contenido></Card>
);}

图形

Your childImageSharp is returning a null value, you can't even query it in the GraphQL playground ( localhost:8000/___graphql ) so in your component, your code is breaking.您的childImageSharp正在返回null值,您甚至无法在 GraphQL 操场( localhost:8000/___graphql )中查询它,因此在您的组件中,您的代码正在中断。

   <Image
    fluid={imagen.sharp.fluid} // Here I try to show
   />

imagen is never getting the data to display a fluid asset since the query is null .由于查询是null ,因此imagen永远不会获取数据来显示fluid资产。

The answer is simple, you need to fix your image path and filesystem to allow Gatsby (and its transformers) to create queryable nodes from your Strapi images, until you don't fix that, you won't be able to use gatsby-image with those assets.答案很简单,您需要修复图像路径和文件系统,以允许 Gatsby(及其转换器)从您的 Strapi 图像创建可查询节点,直到您不修复它,您将无法使用gatsby-image与这些资产。

Have you tried removing "sharp" from your query?您是否尝试过从查询中删除“尖锐”? Just like this:像这样:

imagen {
    childImageSharp {
      fluid(maxWidth: 600, maxHeight: 400) {
        ...GatsbyImageSharpFluid
      }
    }
  }        

You have to put this in the hooks file:你必须把它放在钩子文件中:

  imagen {
      sharp: childImageSharp {
           fluid( maxWidth: 600, maxHeight: 400 ){
               ...GatsbyImageSharpFluid_withWebp
           }
       }
  }

And also if you have the same error you should disable multiple images in the image 'propiedades' strapi type builder而且,如果您遇到相同的错误,您应该在图像“propiedades”strapi 类型构建器中禁用多个图像

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IMDB API 请求 GraphQL 错误 'ClientError: 无法查询类型为“MainSearchEntity”的字段“图像”' - IMDB API request GraphQL Error 'ClientError: Cannot query field "Image" on type "MainSearchEntity"' GraphQL / Relay架构无法在“CreateLinkPayload”类型上查询字段“store” - GraphQL/Relay Schema Cannot query field “store” on type “CreateLinkPayload” NestJs - Graphql 错误无法确定 GraphQL 输入类型<field> . 确保您的 class 已使用合适的装饰器进行装饰</field> - NestJs - Graphql Error Cannot determine a GraphQL input type for the <Field>. Make sure your class is decorated with an appropriate decorator 错误 GraphQL 查询中出现错误:所需类型“String!”的变量“$slug” 没有提供 - error There was an error in your GraphQL query: Variable “$slug” of required type “String!” was not provided GraphQL /中继架构“无法查询字段...” - GraphQL/Relay Schema “Cannot query field…” Gatsby 和 WPGraphQL - 构建错误“无法在类型“查询”上查询字段“页面”” - Gatsby and WPGraphQL - Build Error "Cannot query field "pages" on type "Query"" Gatsby GraphQL 中用于自定义查询的未知字段错误 - Unknow field error in Gatsby GraphQL for custom query Apollo客户端Graphql查询变量类型错误 - Apollo client Graphql query variable type error GraphQL 查询中的错误显示未知类型“ContentfulSizes” - Error in GraphQL query it says Unknown type "ContentfulSizes" GraphQL 查询返回错误“不能为不可为空的字段返回空值” - GraphQL query returns error "Cannot return null for non-nullable field"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM