简体   繁体   中英

Gatsby: gatsby-source-graphql & gatsby-plugin-sharp in graphql query

I am using Gatsby v. 2.0.2. As a headless CMS I am using Strapi. I am trying to use gatsby-image, gatsby-plugin-sharp (image processing) with the pictures uploaded from Strapi.

My folder structure is:

>>projectfolder
   >>api
     >>public
       >>uploads (here my images are located)
   >>frontend (gatsby stuff)

similar to Gatsby-source-wordpress I would like to graphql query images like this:

query {
  api {
    projects {
      image {
        name
        url
        childImageSharp {
          resize(width: 180, height: 180) {
            src
          }
        }
      }
    }
  }
}

If I use the exports.onCreateNode I only get the parent node "api". How can I get the image URL so that createRemoteFileNode can be used?

Do I need to write exports.createPages, graphql query the api-node and then use createNode or createNodeField to create nodes?


I have tried to use to Gatsby-source-strapi with the same problem not being able to reach Gatsby-transformer-sharp.

query {
  allStrapiProject {
    edges {
      node {
        title
        image {
          name
        }
      }
    }
  }
}

这已添加到最近的请求请求中,并将在接下来的几天中在npm上发布: https : //github.com/strapi/gatsby-source-strapi/pull/24

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM