BigDecimal Graphql Js

BigDecimal Graphql Js

我想在 graphql 中声明一个 "BigDecimal" 标量。 我在我的解析器中添加了这个声明:

    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?

我使用 Graphql 的 Float 标量来绕过这个问题