我想声明一个" BigDecimal" graphql中的标量。 我在我的解析器中添加了这个声明:
BigDecimal: new GraphQLScalarType({
name: 'BigDecimal',
description: 'BigDecimal scalar type',
serialize: (value) => value,
parseValue: (value) => value,
parseLiteral: (ast) => {ast.kind === "FloatValue" ? parseFloat(ast.value) : null}
})
但是当我按照以下方式调用我的查询时:
mutation basePost(
numberPost:{
amt:1.111
} )
这给了我这个错误:
"errors": [
{
"message": "Expected type BigDecimal, found 1.111.",
"locations": [
{
"line": 41,
"column": 27
}
]
},
我的输入架构如下:
input numberPost {
amt: BigDecimal
}
我的错误在哪里?是否有另一种方式来为graphql声明bigDecimal?
答案 0 :(得分:1)
我使用了Graphql的Float标量来解决问题