mercurius-upload
Advanced tools
Comparing version 4.0.0 to 5.0.0
/// <reference types="node" /> | ||
import { UploadOptions } from 'graphql-upload' | ||
import processRequest from 'graphql-upload/processRequest.js' | ||
import type { FastifyPluginCallback } from 'fastify' | ||
@@ -10,5 +10,6 @@ declare module 'fastify' { | ||
export declare const mercuriusUpload: FastifyPluginCallback< | ||
UploadOptions, | ||
import('http').Server | ||
processRequest.ProcessRequestOptions, | ||
import('http').Server, | ||
import('fastify').FastifyTypeProviderDefault | ||
> | ||
export default mercuriusUpload |
@@ -10,3 +10,5 @@ 'use strict' | ||
const fastify_plugin_1 = __importDefault(require('fastify-plugin')) | ||
const graphql_upload_1 = require('graphql-upload') | ||
const processRequest_js_1 = __importDefault( | ||
require('graphql-upload/processRequest.js') | ||
) | ||
const mercuriusGQLUpload = (fastify, options, done) => { | ||
@@ -21,3 +23,3 @@ fastify.addContentTypeParser('multipart', (req, _payload, done) => { | ||
} | ||
request.body = await (0, graphql_upload_1.processRequest)( | ||
request.body = await (0, processRequest_js_1.default)( | ||
request.raw, | ||
@@ -24,0 +26,0 @@ reply.raw, |
{ | ||
"name": "mercurius-upload", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"description": "Fastify plugin to support GraphQL uploads using graphql-upload", | ||
@@ -31,26 +31,24 @@ "keywords": [ | ||
"dependencies": { | ||
"@types/graphql-upload": "^8.0.7", | ||
"fastify-plugin": "^3.0.0", | ||
"graphql-upload": "^13.0.0" | ||
"fastify-plugin": "^3.0.1", | ||
"graphql-upload": "^15.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.11.12", | ||
"@types/tap": "^15.0.5", | ||
"@types/node": "^16.11.39", | ||
"@types/tap": "^15.0.7", | ||
"cross-env": "^7.0.3", | ||
"fastify": "^3.24.1", | ||
"fastify": "^4.0.1", | ||
"form-data": "^4.0.0", | ||
"graphql": "^15.8.0", | ||
"mercurius": "^8.11.2", | ||
"prettier": "^2.5.1", | ||
"tap": "^15.1.5", | ||
"ts-node": "^10.4.0", | ||
"typescript": "^4.5.3" | ||
"graphql": "^16.5.0", | ||
"mercurius": "^10.0.0", | ||
"prettier": "^2.6.2", | ||
"tap": "^16.2.0", | ||
"ts-node": "^10.8.1", | ||
"typescript": "^4.7.3" | ||
}, | ||
"peerDependencies": { | ||
"graphql": "0.13.1 - 16" | ||
"graphql": "^16.3.0" | ||
}, | ||
"scripts": { | ||
"test": "tap --ts --100 test/*.test.ts" | ||
}, | ||
"readme": "# mercurius-upload\n\n[graphql-upload](https://github.com/jaydenseric/graphql-upload) implementation plugin for [Fastify](https://www.fastify.io/) & [mercurius](https://github.com/mercurius-js/mercurius).\n\nPlugin made for **Fastify v3**:\n\n## Install\n\n```sh\nyarn add mercurius-upload\n# or\nnpm i mercurius-upload\n# or\npnpm add mercurius-upload\n```\n\n## Usage\n\nPlugin options should conform to https://github.com/jaydenseric/graphql-upload#type-processrequestoptions\n\n```js\nfastify.register(require('mercurius-upload'), {\n // options passed to processRequest from graphql-upload\n})\n```\n\n> or\n\n```ts\nimport MercuriusGQLUpload from 'mercurius-upload'\n\n// ...\n\nfastify.register(MercuriusGQLUpload, {\n // options passed to processRequest from graphql-upload\n})\n```\n\n## Example\n\n```js\nconst GQL = require('mercurius')\nconst { GraphQLUpload } = require('graphql-upload')\nconst fs = require('fs')\nconst util = require('util')\nconst stream = require('stream')\nconst path = require('path')\n\nconst pipeline = util.promisify(stream.pipeline)\nconst uploadsDir = path.resolve(__dirname, '../uploads')\n\nconst schema = /* GraphQL */ `\n scalar Upload\n\n type Query {\n add(x: Int, y: Int): Int\n }\n\n type Mutation {\n uploadImage(image: Upload): Boolean\n }\n`\n\nconst resolvers = {\n Upload: GraphQLUpload,\n Query: {\n add: async (_, { x, y }) => {\n return x + y\n },\n },\n Mutation: {\n uploadImage: async (_, { image }) => {\n const { filename, createReadStream } = await image\n const rs = createReadStream()\n const ws = fs.createWriteStream(path.join(uploadsDir, filename))\n await pipeline(rs, ws)\n return true\n },\n },\n}\n\nmodule.exports = function (fastify, options, done) {\n fastify.register(require('mercurius-upload'))\n\n fastify.register(GQL, {\n schema,\n resolvers,\n graphiql: true,\n })\n\n done()\n}\n```\n" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
48
5599
+ Added@types/busboy@1.5.4(transitive)
+ Added@types/object-path@0.11.4(transitive)
+ Addedbusboy@1.6.0(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addedgraphql-upload@15.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedstreamsearch@1.1.0(transitive)
- Removed@types/graphql-upload@^8.0.7
- Removed@types/accepts@1.3.7(transitive)
- Removed@types/body-parser@1.19.5(transitive)
- Removed@types/connect@3.4.38(transitive)
- Removed@types/content-disposition@0.5.8(transitive)
- Removed@types/cookies@0.9.0(transitive)
- Removed@types/express@5.0.0(transitive)
- Removed@types/express-serve-static-core@5.0.2(transitive)
- Removed@types/graphql-upload@8.0.12(transitive)
- Removed@types/http-assert@1.5.6(transitive)
- Removed@types/http-errors@2.0.4(transitive)
- Removed@types/keygrip@1.0.6(transitive)
- Removed@types/koa@2.15.0(transitive)
- Removed@types/koa-compose@3.2.8(transitive)
- Removed@types/mime@1.3.5(transitive)
- Removed@types/qs@6.9.17(transitive)
- Removed@types/range-parser@1.2.7(transitive)
- Removed@types/send@0.17.4(transitive)
- Removed@types/serve-static@1.15.7(transitive)
- Removedbusboy@0.3.1(transitive)
- Removeddepd@1.1.2(transitive)
- Removeddicer@0.3.0(transitive)
- Removedfs-capacitor@8.0.0(transitive)
- Removedgraphql-upload@13.0.0(transitive)
- Removedhttp-errors@1.8.1(transitive)
- Removedstatuses@1.5.0(transitive)
- Removedstreamsearch@0.1.2(transitive)
Updatedfastify-plugin@^3.0.1
Updatedgraphql-upload@^15.0.1