{"_id":"body-parser-graphql","_rev":"233062","name":"body-parser-graphql","description":"GraphQL server middleware to support application/graphql requests","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"time":{"modified":"2021-06-03T15:47:46.000Z","created":"2018-01-01T09:57:16.626Z","1.1.0":"2018-04-26T14:11:57.292Z","1.0.0":"2018-01-01T09:57:16.626Z"},"users":{},"author":{"name":"Kim Brandwijk","email":"kim.brandwijk@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/supergraphql/body-parser-graphql.git"},"versions":{"1.1.0":{"name":"body-parser-graphql","version":"1.1.0","description":"GraphQL server middleware to support application/graphql requests","main":"dist/index.js","typings":"dist/index.d.ts","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d","test":"nyc cucumber-js --compiler ts:ts-node/register test/features/ -r test/step_definitions/ -f json:test/report/cucumber_report.json","posttest":"node test/createReport.js && nyc report --reporter=text-lcov | coveralls","vscodetest":"nyc --reporter=lcov --reporter=text-summary cucumber-js --compiler ts:ts-node/register test/features/ -r test/step_definitions/ -f ./test/tap-formatter.js","semantic-release":"semantic-release"},"keywords":["graphql","express"],"author":{"name":"Kim Brandwijk","email":"kim.brandwijk@gmail.com"},"license":"MIT","nyc":{"extension":[".ts"],"require":["ts-node/register"],"include":["src/**/*.ts"],"exclude":["**/*.d.ts"],"reporter":["text","lcov","json"],"all":true,"sourceMap":true,"instrument":true},"dependencies":{"body-parser":"^1.18.2"},"devDependencies":{"@types/chai":"4.1.2","@types/chai-http":"3.0.4","@types/cucumber":"3.2.2","@types/express":"4.11.1","@types/node":"9.4.6","chai":"4.1.2","chai-http":"3.0.0","coveralls":"3.0.0","cucumber":"3.2.1","cucumber-html-reporter":"4.0.1","express":"4.16.2","nyc":"11.4.1","semantic-release":"12.4.1","ts-node":"5.0.0","typescript":"2.7.2"},"repository":{"type":"git","url":"git+https://github.com/supergraphql/body-parser-graphql.git"},"bugs":{"url":"https://github.com/supergraphql/body-parser-graphql/issues"},"homepage":"https://github.com/supergraphql/body-parser-graphql#readme","release":{"branch":"master"},"gitHead":"41f5abbd223cfdb6f0a500b5d7fa38f34935a7e5","_id":"body-parser-graphql@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"shasum":"80a80353c7cb623562fd375750dfe018d75f0f7c","size":49281,"noattachment":false,"key":"/body-parser-graphql/-/body-parser-graphql-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/body-parser-graphql/download/body-parser-graphql-1.1.0.tgz"},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/body-parser-graphql_1.1.0_1524751917191_0.9861149874355337"},"_hasShrinkwrap":false,"publish_time":1524751917292,"_cnpm_publish_time":1524751917292},"1.0.0":{"name":"body-parser-graphql","version":"1.0.0","description":"GraphQL server middleware to support application/graphql requests","main":"dist/index.js","typings":"dist/index.d.ts","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d","test":"nyc cucumber-js --compiler ts:ts-node/register test/features/ -r test/step_definitions/ -f json:test/report/cucumber_report.json","posttest":"node test/createReport.js && nyc report --reporter=text-lcov | coveralls","vscodetest":"nyc --reporter=lcov --reporter=text-summary cucumber-js --compiler ts:ts-node/register test/features/ -r test/step_definitions/ -f ./test/tap-formatter.js","semantic-release":"semantic-release"},"keywords":["graphql","express"],"author":{"name":"Kim Brandwijk","email":"kim.brandwijk@gmail.com"},"license":"MIT","nyc":{"extension":[".ts"],"require":["ts-node/register"],"include":["src/**/*.ts"],"exclude":["**/*.d.ts"],"reporter":["text","lcov","json"],"all":true,"sourceMap":true,"instrument":true},"dependencies":{"body-parser":"^1.18.2"},"devDependencies":{"@types/chai":"4.0.10","@types/chai-http":"3.0.3","@types/cucumber":"3.1.1","@types/express":"4.11.0","@types/node":"8.5.2","chai":"4.1.2","chai-http":"3.0.0","condition-circle":"2.0.1","coveralls":"3.0.0","cucumber":"3.2.0","cucumber-html-reporter":"3.0.4","express":"4.16.2","nyc":"11.4.1","semantic-release":"12.0.0","ts-node":"4.1.0","typescript":"2.6.2"},"repository":{"type":"git","url":"git+https://github.com/supergraphql/body-parser-graphql.git"},"bugs":{"url":"https://github.com/supergraphql/body-parser-graphql/issues"},"homepage":"https://github.com/supergraphql/body-parser-graphql#readme","release":{"branch":"master","verifyConditions":"condition-circle"},"gitHead":"0ba47bd51c5936a2625ac137b0a0ab3d26127015","_id":"body-parser-graphql@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"},"dist":{"shasum":"997de1792ed222cbc4845d404f4549eb88ec6d37","size":49255,"noattachment":false,"key":"/body-parser-graphql/-/body-parser-graphql-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/body-parser-graphql/download/body-parser-graphql-1.0.0.tgz"},"maintainers":[{"name":"kbrandwijk","email":"kim.brandwijk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/body-parser-graphql-1.0.0.tgz_1514800636519_0.927813493879512"},"directories":{},"publish_time":1514800636626,"_hasShrinkwrap":false,"_cnpm_publish_time":1514800636626}},"readme":"# body-parser-graphql [![npm](https://img.shields.io/npm/v/body-parser-graphql.svg?style=for-the-badge)](https://www.npmjs.com/package/body-parser-graphql)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge)](https://github.com/semantic-release/semantic-release)[![CircleCI](https://img.shields.io/circleci/project/github/supergraphql/body-parser-graphql.svg?style=for-the-badge)](https://circleci.com/gh/supergraphql/body-parser-graphql)[![Code Climate](https://img.shields.io/codeclimate/maintainability/supergraphql/body-parser-graphql.svg?style=for-the-badge&label=code%20quality)](https://codeclimate.com/github/supergraphql/body-parser-graphql)[![Coveralls](https://img.shields.io/coveralls/github/supergraphql/body-parser-graphql.svg?style=for-the-badge)](https://coveralls.io/github/supergraphql/body-parser-graphql)[![Renovate badge](https://img.shields.io/badge/renovate-enabled-e10079.svg?style=for-the-badge)](https://renovateapp.com/)  \nExpress body-parser that supports the `application/graphql` MIME type.\n\n## How does it work?\n`body-parser-graphql` checks the `Content-Type` header of the request. If the Content-Type is `application/graphql`, the request is transformed into a 'normal' `application/json` GraphQL request, and the `Content-Type` header is set to `application/json`.\n\nReceived request:\n```graphql\n{\n  posts {\n    id\n    title\n  }\n}\n```\n`request.body` value after the middleware:\n```js\n{\n  query: {\n    posts {\n      id\n      title\n    }\n  }\n}\n```\n\nIf an `application/json` request is received, it applies the JSON body-parser.\n\n## Installation\n\nInstall `body-parser-graphql` using your favorite package manager:\n```shell\n$ yarn add body-parser-graphql\n$ npm install body-parser-graphql\n```\n\n## Usage\n\nThe `body-parser-graphql` can be used as a drop-in replacement for the normal `json` body-parser.\n\n```diff\nimport * as express from 'express'\n- import * as bodyParser from 'body-parser'\n+ import * as bodyParser from 'body-parser-graphql'\n\nconst app = express()\n\n- app.use(bodyParser.json())\n+ app.use(bodyParser.graphql())\n\n// Your express routes\n\napp.listen(/* your configuration */)\n```\n\nAlternatively, you can also import the body-parser directly:\n\n```typescript\nimport { bodyParserGraphQL } from 'body-parser-graphql'\n\napp.use(bodyParserGraphQL())\n```\n\n<hr>\n<p align=\"center\">\n  <img src=\"https://img.shields.io/badge/built-with_%F0%9F%92%99-blue.svg?style=for-the-badge\"/><a href=\"https://github.com/kbrandwijk\" target=\"-_blank\"><img src=\"https://img.shields.io/badge/by-kim_brandwijk-blue.svg?style=for-the-badge\"/></a>\n</p>\n","_attachments":{},"homepage":"https://github.com/supergraphql/body-parser-graphql#readme","bugs":{"url":"https://github.com/supergraphql/body-parser-graphql/issues"},"license":"MIT"}