
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
body-parser-graphql
Advanced tools
GraphQL server middleware to support application/graphql requests
Express body-parser that supports the application/graphql
MIME type.
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
.
Received request:
{
posts {
id
title
}
}
request.body
value after the middleware:
{
query: {
posts {
id
title
}
}
}
If an application/json
request is received, it applies the JSON body-parser.
Install body-parser-graphql
using your favorite package manager:
$ yarn add body-parser-graphql
$ npm install body-parser-graphql
The body-parser-graphql
can be used as a drop-in replacement for the normal json
body-parser.
import * as express from 'express'
- import * as bodyParser from 'body-parser'
+ import * as bodyParser from 'body-parser-graphql'
const app = express()
- app.use(bodyParser.json())
+ app.use(bodyParser.graphql())
// Your express routes
app.listen(/* your configuration */)
Alternatively, you can also import the body-parser directly:
import { bodyParserGraphQL } from 'body-parser-graphql'
app.use(bodyParserGraphQL())
FAQs
GraphQL server middleware to support application/graphql requests
The npm package body-parser-graphql receives a total of 16,168 weekly downloads. As such, body-parser-graphql popularity was classified as popular.
We found that body-parser-graphql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.