{"id":21660251,"url":"https://github.com/graphql-middleware/body-parser-graphql","last_synced_at":"2025-04-15T05:25:31.824Z","repository":{"id":28023057,"uuid":"115900244","full_name":"graphql-middleware/body-parser-graphql","owner":"graphql-middleware","description":"GraphQL server middleware to support application/graphql requests","archived":false,"fork":false,"pushed_at":"2024-10-08T19:34:14.000Z","size":171,"stargazers_count":19,"open_issues_count":17,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-13T17:39:05.262Z","etag":null,"topics":["express","graphql"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphql-middleware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-01T04:59:06.000Z","updated_at":"2023-09-22T18:48:18.000Z","dependencies_parsed_at":"2024-02-29T13:42:12.071Z","dependency_job_id":"420c4f75-f05c-4a8e-8ded-e69203c6c167","html_url":"https://github.com/graphql-middleware/body-parser-graphql","commit_stats":{"total_commits":47,"total_committers":4,"mean_commits":11.75,"dds":"0.36170212765957444","last_synced_commit":"41f5abbd223cfdb6f0a500b5d7fa38f34935a7e5"},"previous_names":["supergraphql/body-parser-graphql"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-middleware%2Fbody-parser-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-middleware%2Fbody-parser-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-middleware%2Fbody-parser-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-middleware%2Fbody-parser-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-middleware","download_url":"https://codeload.github.com/graphql-middleware/body-parser-graphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249011969,"owners_count":21198127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","graphql"],"created_at":"2024-11-25T09:32:33.494Z","updated_at":"2025-04-15T05:25:31.807Z","avatar_url":"https://github.com/graphql-middleware.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"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\u0026label=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\u003chr\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/built-with_%F0%9F%92%99-blue.svg?style=for-the-badge\"/\u003e\u003ca href=\"https://github.com/kbrandwijk\" target=\"-_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/by-kim_brandwijk-blue.svg?style=for-the-badge\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-middleware%2Fbody-parser-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-middleware%2Fbody-parser-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-middleware%2Fbody-parser-graphql/lists"}