Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
mercurius-upload
Advanced tools
graphql-upload implementation plugin for Fastify & mercurius.
Plugin made for Fastify v3:
yarn add mercurius-upload
# or
npm i mercurius-upload
Plugin options should conform to https://github.com/jaydenseric/graphql-upload#type-processrequestoptions
fastify.register(require('mercurius-upload'), {
// options passed to processRequest from graphql-upload
})
or
import MercuriusGQLUpload from 'mercurius-upload'
// ...
fastify.register(MercuriusGQLUpload)
const GQL = require('mercurius')
const { GraphQLUpload } = require('graphql-upload')
const fs = require('fs')
const util = require('util')
const stream = require('stream')
const path = require('path')
const pipeline = util.promisify(stream.pipeline)
const uploadsDir = path.resolve(__dirname, '../uploads')
const schema = /* GraphQL */ `
scalar Upload
type Query {
add(x: Int, y: Int): Int
}
type Mutation {
uploadImage(image: Upload): Boolean
}
`
const resolvers = {
Upload: GraphQLUpload,
Query: {
add: async (_, { x, y }) => {
return x + y
},
},
Mutation: {
uploadImage: async (_, { image }) => {
const { filename, createReadStream } = await image
const rs = createReadStream()
const ws = fs.createWriteStream(path.join(uploadsDir, filename))
await pipeline(rs, ws)
return true
},
},
}
module.exports = function (fastify, options, done) {
fastify.register(require('mercurius-upload'))
fastify.register(GQL, {
schema,
resolvers,
graphiql: true,
})
done()
}
FAQs
Fastify plugin to support GraphQL uploads using graphql-upload
The npm package mercurius-upload receives a total of 0 weekly downloads. As such, mercurius-upload popularity was classified as not popular.
We found that mercurius-upload demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.