UNPKG

graphql-scalars

Version:

A collection of scalar types not included in base GraphQL.

23 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const definition_1 = require("graphql/type/definition"); const error_1 = require("graphql/error"); const language_1 = require("graphql/language"); const utilities_1 = require("./utilities"); exports.default = new definition_1.GraphQLScalarType({ name: 'NegativeFloat', description: 'Floats that will have a value less than 0.', serialize(value) { return utilities_1.processValue(value, utilities_1.VALIDATIONS.NegativeFloat); }, parseValue(value) { return utilities_1.processValue(value, utilities_1.VALIDATIONS.NegativeFloat); }, parseLiteral(ast) { if (ast.kind !== language_1.Kind.FLOAT) { throw new error_1.GraphQLError(`Can only validate floating point numbers as negative floating point numbers but got a: ${ast.kind}`); } return utilities_1.processValue(ast.value, utilities_1.VALIDATIONS.NegativeFloat); }, }); //# sourceMappingURL=NegativeFloat.js.map