【问题标题】:Gatsby Schema Depracation Warning: Inferred ResolversGatsby 模式弃用警告:推断的解析器
【发布时间】:2020-11-17 23:50:49
【问题描述】:

在我的 gatsby 中的 graphQL 模式中,我收到了关于推断解析器的弃用通知。当我声明一个列表时,这是我的语法:

List: [List]

然后在那个节点之外,我这样定义它。

 List: `
     subfield1: String
     subfield2: String
      `,

我已尝试添加 @link(from: "...") 扩展来删除此弃用通知,但似乎没有任何效果,要么节点未正确获取,要么我仍然收到弃用通知。 这是实际的弃用通知:

warn Deprecation warning - adding inferred resolver for field ...

【问题讨论】:

    标签: javascript node.js graphql schema gatsby


    【解决方案1】:

    您可能会收到此弃用警告,因为您的类型定义中没有 @infer@dontInfer。虽然没有更多代码,但很难说。

    以下是对我有用的示例:

    exports.createSchemaCustomization = ({
      actions: { createTypes }
    }) => {
      const myFirstType = 'someTypeName';
      const mySecondType = 'someOtherTypeName';
        const typeDefs = `
          type ${myFirstType} implements Node @dontInfer{
            id: String
            filesArray: [File]
            trueOrFalse: Boolean
            aSpecialDate: Date
          }
          type ${mySecondType} implements Node @infer{
            date: Date @dateformat
            singleFile: File @fileByRelativePath
            authorByEmail: Author @link
          }
        `;
        createTypes(typeDefs);
    }
    

    参考:我从这里开始 https://github.com/panr/gatsby-starter-hello-friend/pull/10 到这里 https://www.gatsbyjs.com/blog/2019-05-17-improvements-to-schema-customization/#migrating-your-code

    PS。我应该指出,我对 GraphQL 和 Gatsby 的“内部工作”完全陌生。该解决方案为我解决了弃用警告。希望它可以帮助其他任何在整个 GraphQL 模式定制方面苦苦挣扎的人。

    【讨论】:

      猜你喜欢
      • 2021-11-22
      • 2021-05-12
      • 2019-04-19
      • 1970-01-01
      • 2020-03-24
      • 1970-01-01
      • 2020-01-22
      • 2021-09-27
      • 2021-05-06
      相关资源
      最近更新 更多