How to use the graphql-upload.processRequest function in graphql-upload

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 code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moleculerjs / moleculer-apollo-server / src / ApolloServer.js View on Github external
return async (req, res) => {
			this.graphqlPath = path || "/graphql";

			await promiseWillStart;

			// If file uploads are detected, prepare them for easier handling with
			// the help of `graphql-upload`.
			if (this.uploadsConfig) {
				const contentType = req.headers["content-type"];
				if (contentType && contentType.startsWith("multipart/form-data")) {
					req.filePayload = await processRequest(req, res, this.uploadsConfig);
				}
			}

			// If health checking is enabled, trigger the `onHealthCheck`
			// function when the health check URL is requested.
			if (!disableHealthCheck && req.url === "/.well-known/apollo/server-health")
				return await this.handleHealthCheck({ req, res, onHealthCheck });

			// If the `playgroundOptions` are set, register a `graphql-playground` instance
			// (not available in production) that is then used to handle all
			// incoming GraphQL requests.
			if (this.playgroundOptions && req.method === "GET") {
				const { mediaTypes } = accept.parseAll(req.headers);
				const prefersHTML =
					mediaTypes.find(x => x === "text/html" || x === "application/json") ===
					"text/html";

graphql-upload

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis