instanceof not working with Decimal

This commit is contained in:
Ulf Gebhardt 2022-02-27 03:09:53 +01:00
parent 003090ed6c
commit 2c77785b77
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -1,14 +1,11 @@
import { GraphQLScalarType, Kind } from 'graphql'
import Decimal from 'decimal.js-light'
import Decimal from '../../util/decimal'
export default new GraphQLScalarType({
name: 'Decimal',
description: 'The `Decimal` scalar type to represent currency values',
serialize(value: unknown) {
if (!(value instanceof Decimal)) {
throw new Error('DecimalScalar can only serialize Decimal values')
}
serialize(value: Decimal) {
return value.toString()
},