@kiyasov/platform-hono 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,75 +1,6 @@
|
|
|
1
1
|
import { Upload } from "./Upload";
|
|
2
2
|
import { ASTNode, GraphQLError, GraphQLScalarType } from "graphql";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* A GraphQL `Upload` scalar that can be used in a
|
|
6
|
-
* [`GraphQLSchema`](https://graphql.org/graphql-js/type/#graphqlschema).
|
|
7
|
-
* It's value in resolvers is a promise that resolves
|
|
8
|
-
* [file upload details]{@link FileUpload} for processing and storage.
|
|
9
|
-
* @example <caption>Ways to `import`.</caption>
|
|
10
|
-
* ```js
|
|
11
|
-
* import { GraphQLUpload } from 'graphql-upload-ts';
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* ```js
|
|
15
|
-
* import GraphQLUpload from 'graphql-upload-ts/dist/GraphQLUpload.js';
|
|
16
|
-
* ```
|
|
17
|
-
* @example <caption>Ways to `require`.</caption>
|
|
18
|
-
* ```js
|
|
19
|
-
* const { GraphQLUpload } = require('graphql-upload-ts');
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* ```js
|
|
23
|
-
* const GraphQLUpload = require('graphql-upload-ts/dist/GraphQLUpload');
|
|
24
|
-
* ```
|
|
25
|
-
* @example <caption>Setup for a schema built with [`makeExecutableSchema`](https://apollographql.com/docs/graphql-tools/generate-schema#makeExecutableSchema).</caption>
|
|
26
|
-
* ```js
|
|
27
|
-
* const { makeExecutableSchema } = require('graphql-tools');
|
|
28
|
-
* const { GraphQLUpload } = require('graphql-upload-ts');
|
|
29
|
-
*
|
|
30
|
-
* const schema = makeExecutableSchema({
|
|
31
|
-
* typeDefs: /* GraphQL *\/ `
|
|
32
|
-
* scalar Upload
|
|
33
|
-
* `,
|
|
34
|
-
* resolvers: {
|
|
35
|
-
* Upload: GraphQLUpload,
|
|
36
|
-
* },
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
* @example <caption>A manually constructed schema with an image upload mutation.</caption>
|
|
40
|
-
* ```js
|
|
41
|
-
* const {
|
|
42
|
-
* GraphQLSchema,
|
|
43
|
-
* GraphQLObjectType,
|
|
44
|
-
* GraphQLBoolean,
|
|
45
|
-
* } = require('graphql');
|
|
46
|
-
* const { GraphQLUpload } = require('graphql-upload-ts');
|
|
47
|
-
*
|
|
48
|
-
* const schema = new GraphQLSchema({
|
|
49
|
-
* mutation: new GraphQLObjectType({
|
|
50
|
-
* name: 'Mutation',
|
|
51
|
-
* fields: {
|
|
52
|
-
* uploadImage: {
|
|
53
|
-
* description: 'Uploads an image.',
|
|
54
|
-
* type: GraphQLBoolean,
|
|
55
|
-
* args: {
|
|
56
|
-
* image: {
|
|
57
|
-
* description: 'Image file.',
|
|
58
|
-
* type: GraphQLUpload,
|
|
59
|
-
* },
|
|
60
|
-
* },
|
|
61
|
-
* async resolve(parent, { image }) {
|
|
62
|
-
* const { filename, fieldName, mimetype, createReadStream } = await image;
|
|
63
|
-
* const stream = createReadStream();
|
|
64
|
-
* // Promisify the stream and store the file, then…
|
|
65
|
-
* return true;
|
|
66
|
-
* },
|
|
67
|
-
* },
|
|
68
|
-
* },
|
|
69
|
-
* }),
|
|
70
|
-
* });
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
4
|
export const GraphQLUpload = new GraphQLScalarType({
|
|
74
5
|
name: "Upload",
|
|
75
6
|
description: "The `Upload` scalar type represents a file upload.",
|