graphql - Gatsby:graphql 查询中的 gatsby-source-graphql 和 gatsby-plugin-sharp
问题描述
我正在使用 Gatsby v. 2.0.2。作为一个无头 CMS,我正在使用 Strapi。我正在尝试对从 Strapi 上传的图片使用 gatsby-image、gatsby-plugin-sharp(图像处理)。
我的文件夹结构是:
>>projectfolder
>>api
>>public
>>uploads (here my images are located)
>>frontend (gatsby stuff)
类似于 Gatsby-source-wordpress 我想像这样使用 graphql 查询图像:
query {
api {
projects {
image {
name
url
childImageSharp {
resize(width: 180, height: 180) {
src
}
}
}
}
}
}
如果我使用exports.onCreateNode,我只会得到父节点“api”。如何获取图像 URL 以便可以使用 createRemoteFileNode?
我是否需要编写exports.createPages,graphql 查询api-node,然后使用createNode 或createNodeField 创建节点?
我曾尝试使用 Gatsby-source-strapi,但同样的问题无法到达 Gatsby-transformer-sharp。
query {
allStrapiProject {
edges {
node {
title
image {
name
}
}
}
}
}
解决方案
这已在最近的拉取请求中添加,并将在接下来的几天内发布在 npm 上:https ://github.com/strapi/gatsby-source-strapi/pull/24 。
推荐阅读
- c# - .NET 应用程序之间的状态和无服务器连接
- google-apps-script - 如何使用 Google 表格宏中的计算值来设置在 FormulaArray 中计算的数组的端点?
- python - Flask-sqlalchemy Rowproxy 无法修改
- assembly - 将移位的立即值加载到寄存器中的单条指令?
- javascript - 背景交叉淡入淡出过渡javascript和css
- azure-cosmosdb - 从 Azure 数据工厂副本导入 CosmosDB 中的 JSON 数据时出现问题
- java - 在 Heroku 上部署 jhipster 应用程序时出现 PostgreSQL 错误
- oracle - ORA-32031: WITH 子句中查询名称的非法引用
- java - 如何从 .lua 文件中解析/读取特定数据?
- python - 数据帧中数据的遍历和操作