【问题标题】:Numbers are converted to strings in GraphQL when using gatsby-source-google-spreadsheet plugin with GatsBy将 gatsby-source-google-spreadsheet 插件与 GatsBy 一起使用时,数字在 GraphQL 中被转换为字符串
【发布时间】:2021-12-20 01:56:16
【问题描述】:

我正在使用 Gatsby,并尝试使用电子表格文件作为后端数据,因此我更喜欢使用 gatsby-source-google-spreadsheet 插件将电子表格转换为 GraphQL。 正如你在这张图片中看到的,我的数据格式是数字: 但是在将数据传输到 GraphQL 后,格式更改为 String

如何在 GraphQL 中获取数字? 我可以在电子表格或插件中进行任何配置吗?

【问题讨论】:

  • 也许您可以在执行 graphql 查询时转换结果。例如。请求score:[Int] 而不仅仅是score
  • 你能分享一份你的工作表吗?
  • @player0 不,我不能这样做,但正如我在问题部分所说,所有数据都有数字格式。

标签: google-sheets graphql gatsby


【解决方案1】:

使用这个插件

gatsby-source-google-sheets https://www.gatsbyjs.com/plugins/gatsby-source-google-sheets/

您使用的是旧版本的“Gatsby-source-google-sheet”npm 插件。 你应该更新这个 npm 插件,你必须在 "gatsby-source-google-sheet" 之后添加 "s" 字符

按照更新命令行“npm i gatsby-source-google-sheets”或“yarn add gatsby-source-google-sheets”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-18
    • 2020-08-11
    • 2021-05-08
    • 2019-12-10
    • 2020-04-20
    • 2020-12-18
    • 2020-07-23
    • 2019-11-04
    相关资源
    最近更新 更多