UNPKG

graphql-extra-scalars

Version:

Collection of extra GraphQL scalar types like Email, URL, Password and more

18 lines (17 loc) 773 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const graphql_1 = require("graphql"); const literalParser_1 = require("../literalParser"); const regexpTypeCoercer_1 = require("../regexpTypeCoercer"); const coerceType = regexpTypeCoercer_1.createRegexpTypeCoercer('MacAddress', /^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/ui); const GraphQLMacAddress = new graphql_1.GraphQLScalarType({ name: 'MacAddress', description: 'The MacAddress scalar type represents a MAC address.', serialize: (value) => { const coercedValue = coerceType(value); return coercedValue.toUpperCase(); }, parseValue: coerceType, parseLiteral: literalParser_1.createParseLiteral(coerceType), }); exports.GraphQLMacAddress = GraphQLMacAddress;