How to use the graphql-upload.GraphQLUpload 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 apollographql / apollo-server / packages / apollo-server-core / src / index.ts View on Github external
) => DocumentNode = gqlTag;

import runtimeSupportsUploads from './utils/runtimeSupportsUploads';
import { GraphQLScalarType } from 'graphql';
export { default as processFileUploads } from './processFileUploads';

// This is a conditional export intended to avoid traversing the
// entire module tree of `graphql-upload`.  This only defined if the
// version of Node.js is >= 8.5.0 since those are the only Node.js versions
// which are supported by `graphql-upload@8`.  Since the source of
// `graphql-upload` is not transpiled for older targets (in fact, it includes
// experimental ECMAScript modules), this conditional export is necessary
// to avoid modern ECMAScript from failing to parse by versions of Node.js
// which don't support it (yet — eg. Node.js 6 and async/await).
export const GraphQLUpload = runtimeSupportsUploads
  ? (require('graphql-upload').GraphQLUpload as GraphQLScalarType)
  : undefined;
github qmit-pro / moleculer-api / dist / schema / plugin / protocol / graphql / handler / options.js View on Github external
"use strict";
/*
  GraphQL Plugin default options for base schema and resolvers
*/
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const apollo_server_caching_1 = require("apollo-server-caching");
const graphql_upload_1 = require("graphql-upload");
const graphql_type_json_1 = require("graphql-type-json");
const graphql_iso_date_1 = require("graphql-iso-date");
// TODO: as preset
delete graphql_upload_1.GraphQLUpload.description;
delete graphql_type_json_1.GraphQLJSON.description;
delete graphql_iso_date_1.GraphQLDate.description;
delete graphql_iso_date_1.GraphQLDateTime.description;
delete graphql_iso_date_1.GraphQLTime.description;
const typeDefs = [];
const resolvers = {};
/* default scalar types */
typeDefs.push(`
"""
Upload scalar type
@input: [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec)
@output: { filename, mimetype, encoding, createReadStream }
filename          string    File name.
mimetype          string    File MIME type. Provided by the client and can’t be trusted.
encoding          string    File stream transfer encoding.
createReadStream  Function  Returns a Node.js readable stream of the file contents, for processing and storing the file. Multiple calls create independent streams. Throws if called after all resolvers have resolved, or after an error has interrupted the request.
github qmit-pro / moleculer-api / dist / schema / plugin / protocol / graphql / handler / options.js View on Github external
const typeDefs = [];
const resolvers = {};
/* default scalar types */
typeDefs.push(`
"""
Upload scalar type
@input: [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec)
@output: { filename, mimetype, encoding, createReadStream }
filename          string    File name.
mimetype          string    File MIME type. Provided by the client and can’t be trusted.
encoding          string    File stream transfer encoding.
createReadStream  Function  Returns a Node.js readable stream of the file contents, for processing and storing the file. Multiple calls create independent streams. Throws if called after all resolvers have resolved, or after an error has interrupted the request.
"""
scalar Upload
`);
resolvers.Upload = graphql_upload_1.GraphQLUpload;
typeDefs.push(`
"""
JSON scalar type
@input: JSON string
@output: Result of JSON.parse(@input)
"""
scalar JSON
`);
resolvers.JSON = graphql_type_json_1.GraphQLJSON;
typeDefs.push(`
"""
Date scalar type
@input: RFC3339 full-date string: "2007-12-03"
@output: Date instance
"""
scalar Date

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

56 / 100
Full package analysis