【问题标题】:.GraphQL missing type after importing another .graphql.GraphQL 导入另一个 .graphql 后缺少类型
【发布时间】:2019-09-06 15:47:04
【问题描述】:

您好,我正在学习 GraphQL。在学习过程中,我发现在硬编码 .js 文件中创建 Schema 是个好主意,最好使用 .graphql 文件目录来编写字段等。

我安装了 babel-plugin-import-graphql 用于导入其他 .graphql 文件,但是当我运行服务器时,我总是收到 missing type Otp

.rootGraphql

#import Otp from "ac.graphql"

type Query {
    Otp: Otp
}

.ac.graphql

type Otp {
    mobilenumber(no: String!): String
}

【问题讨论】:

    标签: graphql graphql-js


    【解决方案1】:

    假设您指向 ac.graphql 的正确文件路径,请尝试以下操作:

    type Query { otp: Otp }

    属性名使用小写,属性type使用大写。

    您不能使用大写的Otp 作为属性名,因为它会与导入的Otp 冲突类型

    (对于其他类型,您可以使用大写的属性名称,但通常最好将您的类型/类大写并小写所有实例化。)

    【讨论】:

      猜你喜欢
      • 2020-01-19
      • 1970-01-01
      • 2020-08-12
      • 2020-07-30
      • 2019-10-09
      • 2018-02-08
      • 1970-01-01
      • 2019-03-26
      • 2021-05-30
      相关资源
      最近更新 更多