UNPKG

body-parser-graphql

Version:

GraphQL server middleware to support application/graphql requests

19 lines 647 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var bodyParser = require("body-parser"); exports.bodyParserGraphQL = function (options) { return function (req, res, next) { if (req.is('application/graphql')) { bodyParser.text({ type: 'application/graphql' })(req, res, function () { req.headers['content-type'] = 'application/json'; req.body = { query: req.body }; next(); }); } else { bodyParser.json(options)(req, res, next); } }; }; exports.graphql = exports.bodyParserGraphQL; //# sourceMappingURL=index.js.map