【问题标题】:GraphQL-Tools On SchemaErrorGraphQL-Tools On SchemaError
【发布时间】:2018-03-04 14:14:09
【问题描述】:

我可能在某个地方犯了一个新手错误,但为什么控制台告诉我提供 typeDefs?当我通过在下面的文件中使用 javascript 中的导出默认值提供一个时。我尝试重新安装软件包等,但仍然出现同样的错误。

schema.js:

export default `
    type Query {
        hi: String
    }
`;

然后是我的 app.js 的截图和错误:

我也试过这种定义和导出的方式,还是得到“必须提供typeDefs”,这是教程里的schema.js:

const typeDefs = `
    type Query {
        hi: String
    }
`;

export default typeDefs;

【问题讨论】:

    标签: javascript graphql apollo


    【解决方案1】:

    您在类型定义中使用默认导出,但尝试在 app.js 中导入命名导出。相反,导入应该如下所示:

    import typeDefs from './server/schemas/schema'
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-01
    • 2018-01-11
    • 2019-03-22
    • 2018-09-24
    • 2021-10-11
    • 1970-01-01
    • 2018-05-29
    • 2020-09-16
    相关资源
    最近更新 更多