graphql-framework-experiment
graphql-framework-experiment copied to clipboard
Large request - bodyParser - missing query field
Sorry if it shouldn't be in this category.
Nexus Report
■ nexus:server:graphql BadRequestError: Invalid body: request entity too large.
Description
I am using graphql-upload and this error occurect. I tried to use bodyParser to solve it like so:
server.express.use(bodyParser.json({type: 'application/json', limit: '10mb'}))
but it throwed another error that
■ nexus:server:graphql BadRequestError: request.body json expected to have a query field
Any ideas how to make it work? Thanks
Check that you're not using two different versions of graphql-upload. apollo-server-core bundles an older one.
Check that you're not using two different versions of
graphql-upload.apollo-server-corebundles an older one.
What exactly do you mean? I'am using just "graphql-upload": "^11.0.0". I don't have apollo-server-core nowhere installed.
"dependencies": {
"@types/bcryptjs": "^2.4.2",
"@types/graphql-upload": "^8.0.3",
"@types/jsonwebtoken": "^8.5.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"body-parser-graphql": "^1.1.0",
"graphql-upload": "^11.0.0",
"jsonwebtoken": "^8.5.1",
"nexus": "0.25.0",
"nexus-plugin-jwt-auth": "^1.2.0",
"nexus-plugin-prisma": "0.16.1"
},
This is my app.ts
import { settings, use, server } from 'nexus'
import { prisma } from 'nexus-plugin-prisma'
import { auth } from 'nexus-plugin-jwt-auth'
import { PrismaClient } from 'nexus-plugin-prisma/client'
import { APP_SECRET } from './utils/index'
import * as bodyParser from 'body-parser'
const prismaClient = new PrismaClient()
server.express.use(bodyParser.json({type: 'application/json', limit: '1mb'}))
use(
prisma({
client: { instance: prismaClient },
features: {
crud: true,
}
})
)
use(
auth({
appSecret: APP_SECRET,
})
)
settings.change({
server: {
startMessage: (info) => {
settings.original.server.startMessage(info)
},
},
})
What exactly do you mean? I'am using just
"graphql-upload": "^11.0.0". I don't haveapollo-server-corenowhere installed.
Ah, sorry for being a bit unclear - I should've added that nexus in the next versions uses apollo-server-express and thus apollo-server-core which in turn uses an older graphql-upload. npm ls graphql-upload (or similar command with yarn) shows the installed versions.
@mipyykko
I traced graphql-upload versions in the repository and there is just newest version installed. I have new version of nexus which use apollo-server-express.
yarn list v1.22.4
├─ @types/[email protected]
└─ [email protected]
By the look of it, it should be ok right? I still don't know where could be a problem. All packages are uptodate, all settings are correct(hopefully).
Problem with bodyParser for file uploads is not resolved, but I probably found solution.
Use this middleware instead of bodyParser
import { graphqlUploadExpress } from 'graphql-upload'
server.express.use('/graphql', graphqlUploadExpress({
maxFileSize: 50_000
}))