UNPKG

@nestjs/graphql

Version:

Nest - modern, fast, powerful node.js web framework (@graphql)

21 lines (20 loc) 748 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createScalarType = createScalarType; const graphql_1 = require("graphql"); function bindInstanceContext(instance, funcKey) { return instance[funcKey] ? instance[funcKey].bind(instance) : undefined; } function createScalarType(name, instance) { return new graphql_1.GraphQLScalarType({ name, description: instance.description, specifiedByURL: instance.specifiedByURL, extensions: instance.extensions, parseValue: bindInstanceContext(instance, 'parseValue'), serialize: bindInstanceContext(instance, 'serialize'), parseLiteral: bindInstanceContext(instance, 'parseLiteral'), }); }