GraphQLUpload with processRequest on apollo-server-micro not working
See original GitHub issueWhen uploading a file im getting the following error.
Server code:
const apolloServer = new ApolloServer({
credentials: true,
typeDefs: mergeTypeDefs(loadFilesSync(path.join(process.cwd(), 'graphql/schemas'))),
resolvers: mergeResolvers([...Mutation, ...Query, ...types]),
context: async ({ req, res }) => {
const username = req.session.get('username')
return { db, req, res, username, user: username && await db.models.user.findByPk(username) }
}
})
const startServer = apolloServer.start()
export default withSession(async (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Credentials', 'true')
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
const contentType = req.headers['content-type']
if (contentType && contentType.startsWith('multipart/form-data')) {
req.filePayload = await processRequest(req, res)
}
await db.sync()
await startServer
return apolloServer.createHandler({ path: '/api/graphql' })(req, res)
})
export const config = {
api: { bodyParser: false }
}
Resolvers object:
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Not able to upload files above 1MB using apollo-server-micro ...
This is working for smaller files, but it somehow seems to be blocking my larger files. When I upload the file, I get...
Read more >File uploads - Apollo GraphQL Docs
Some integrations might need to use graphql-upload 's processRequest directly. ... local-file-output.txt in the current working directory on EACH upload.
Read more >apollo-server-micro | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Top 5 graphql-upload Code Examples - Snyk
To help you get started, we've selected a few graphql-upload examples, based on popular ways it is used in public projects. Secure your...
Read more >graphql-upload-minimal - npm
Minimalistic and developer friendly middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sounds like something weird about how dependencies are installed and resolved in your project.
BTW, it’s best to skip the index module and directly deep import the thing you need:
Or for your funny workaround:
It is,
yarn why
showed the direct graphql-upload dependency as the only one. But it seems a similar problem as other similar issues was the culprit.Solved by using the full path to import the Scalar:
import { GraphQLUpload } from 'node_modules/graphql-upload/public/index.js'