ontotext-platform-custom-scalars
Version:
A library of customized GraphQL scalars for Ontotext Platform
32 lines (26 loc) • 868 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _graphql = require("graphql");
var _Utilities = require("../Utilities");
// defines max values allowed for the current type
var MAX_VALUE = Math.pow(2, 8) - 1;
/**
* Defines custom GraphQLScalarType for unsigned byte values.
*/
var _default = new _graphql.GraphQLScalarType({
name: "UnsignedByte",
description: "Unsigned 8-bit integer",
serialize: function serialize(value) {
return (0, _Utilities.parseUnsignedValue)(value, MAX_VALUE, this.name);
},
parseValue: function parseValue(value) {
return (0, _Utilities.parseUnsignedValue)(value, MAX_VALUE, this.name);
},
parseLiteral: function parseLiteral(node) {
return (0, _Utilities.parseUnsignedLiteral)(node, MAX_VALUE, this.name);
}
});
exports["default"] = _default;