UNPKG

ontotext-platform-custom-scalars

Version:
40 lines (30 loc) 917 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _graphql = require("graphql"); var _Utilities = require("./Utilities"); function convert(value) { if ((0, _Utilities.isNumber)(value)) { return value + ''; } throw new _graphql.GraphQLError("Expected 'Decimal' value, but got ".concat(value)); } /** * Defines custom GraphQLScalarType for Decimal values. */ var _default = new _graphql.GraphQLScalarType({ name: "Decimal", description: "Decimal infinite-precision number", serialize: convert, parseValue: convert, parseLiteral: function parseLiteral(node) { var type = node.kind; if (type !== _graphql.Kind.FLOAT && type !== _graphql.Kind.INT && type !== _graphql.Kind.STRING) { (0, _Utilities.throwConversionError)(type, this.name); } return convert(node.value); } }); exports["default"] = _default;