forked from jaydenseric/graphql-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphQLUpload.d.ts
63 lines (63 loc) · 2.03 KB
/
GraphQLUpload.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
export = GraphQLUpload;
/** @typedef {import("./processRequest").FileUpload} FileUpload */
/**
* A GraphQL `Upload` scalar that can be used in a
* [`GraphQLSchema`](https://graphql.org/graphql-js/type/#graphqlschema). It’s
* value in resolvers is a promise that resolves
* {@link FileUpload file upload details} for processing and storage.
* @example
* A schema built using
* [`makeExecutableSchema`](https://www.graphql-tools.com/docs/api/modules/schema_src#makeexecutableschema)
* from [`@graphql-tools/schema`](https://npm.im/@graphql-tools/schema):
*
* ```js
* const { makeExecutableSchema } = require("@graphql-tools/schema");
* const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
*
* const schema = makeExecutableSchema({
* typeDefs: `
* scalar Upload
* `,
* resolvers: {
* Upload: GraphQLUpload,
* },
* });
* ```
* @example
* A manually constructed schema with an image upload mutation:
*
* ```js
* const { GraphQLSchema, GraphQLObjectType, GraphQLBoolean } = require("graphql");
* const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
*
* const schema = new GraphQLSchema({
* mutation: new GraphQLObjectType({
* name: "Mutation",
* fields: {
* uploadImage: {
* description: "Uploads an image.",
* type: GraphQLBoolean,
* args: {
* image: {
* description: "Image file.",
* type: GraphQLUpload,
* },
* },
* async resolve(parent, { image }) {
* const { filename, mimetype, createReadStream } = await image;
* const stream = createReadStream();
* // Promisify the stream and store the file, then…
* return true;
* },
* },
* },
* }),
* });
* ```
*/
declare const GraphQLUpload: GraphQLScalarType<Promise<import("./processRequest").FileUpload>, never>;
declare namespace GraphQLUpload {
export { FileUpload };
}
import { GraphQLScalarType } from "graphql";
type FileUpload = import("./processRequest").FileUpload;