gpt4 book ai didi

mysql - GraphQL : must be Output Type but got: undefined Error

转载 作者:行者123 更新时间:2023-11-29 05:49:19 24 4
gpt4 key购买 nike

我试图从数据库中获取一个 MySQL 日期并使用 graphql 输出它。我的应用程序构建和运行没有任何问题。但是在 graphql ui 中,它显示以下错误。

{
"errors": [
{
"message": "The type of Tour.arrival_date must be Output Type but got: undefined."
}
]
}

我的 type.js 文件如下所示。

let {
GraphQLID,
GraphQLString,
GraphQLInt,
GraphQLFloat,
GraphQLObjectType,
GraphQLNonNull,
GraphQLDate,
GraphQLList
} = require('graphql')




// Defines the type
module.exports = new GraphQLObjectType({
name: 'Tour',
description: 'A Tour',
fields: {
id: {
type: new GraphQLNonNull(GraphQLID)
},
name: {
type: new GraphQLNonNull(GraphQLString)
},
pax_count: {
type: GraphQLInt
},
arrival_date: {
type: GraphQLDate
}

}
})

我正在为 ISO 日期使用以下库。

https://www.npmjs.com/package/graphql-iso-date

有人可以告诉我这可能是什么问题吗?请注意,我是 GraphQL 的新手。

谢谢佛系

最佳答案

您正在从 graphql 导入 GraphQLDate,但 graphql 不会导出具有该名称的变量,因为没有内置标量GraphQL.js 中的日期。如果您使用的是 graphql-iso-date,请按照文档中的说明导入适当的标量:

const { GraphQLDate } = require('graphql-iso-date')

关于mysql - GraphQL : must be Output Type but got: undefined Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55926278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com