1
1
import { Field , InputType , ObjectType } from '@nestjs/graphql' ;
2
+ import { stripIndent } from 'common-tags' ;
3
+ import UploadScalar from 'graphql-upload/GraphQLUpload.mjs' ;
4
+ import type { FileUpload } from 'graphql-upload/Upload.mjs' ;
2
5
import { ID , IdField } from '~/common' ;
3
6
import { MediaUserMetadata } from '../media/media.dto' ;
4
7
@@ -8,22 +11,44 @@ export abstract class RequestUploadOutput {
8
11
readonly id : ID ;
9
12
10
13
@Field ( {
11
- description : 'A pre-signed url to upload the file to' ,
14
+ description : stripIndent `
15
+ A temporary url to upload the file to.
16
+ It should be a an HTTP PUT request with the file as the body.
17
+ The Content-Type header should be set to the mime type of the file.
18
+ ` ,
12
19
} )
13
20
readonly url : string ;
14
21
}
15
22
16
23
@InputType ( )
17
24
export abstract class CreateDefinedFileVersionInput {
18
25
@IdField ( {
19
- description : 'The ID returned from the `requestFileUpload` mutation' ,
26
+ description : stripIndent `
27
+ The ID returned from the \`requestFileUpload\` mutation.
28
+ This _can_ be skipped if \`file\` is provided.
29
+ ` ,
30
+ nullable : true ,
31
+ } )
32
+ readonly uploadId ?: ID ;
33
+
34
+ @Field ( ( ) => UploadScalar , {
35
+ description : stripIndent `
36
+ A file directly uploaded.
37
+ This is mainly here to allow usage with Apollo Studio/Sandbox.
38
+ For production, prefer the \`url\` from the \`RequestUploadOutput\`.
39
+ ` ,
40
+ nullable : true ,
20
41
} )
21
- readonly uploadId : ID ;
42
+ readonly file ?: Promise < FileUpload > ;
22
43
23
44
@Field ( {
24
- description : 'The file name' ,
45
+ description : stripIndent `
46
+ The file name. This is generally required.
47
+ It's only optional if \`file\` is provided.
48
+ ` ,
49
+ nullable : true ,
25
50
} )
26
- readonly name : string ;
51
+ readonly name ? : string ;
27
52
28
53
@Field ( {
29
54
description :
0 commit comments