Skip to main content

File Uploads

Uploading files is a common of part of applications and we need a way to support that.


const gqlFileUpload: CustomType = {
type: "GraphQLUpload",
importPath: "graphql-upload",
tsType: "FileUpload",
tsImportPath: "graphql-upload",

gqlFileUpload uses the graphql-upload package to support File Uploads. It's also a good example of CustomType usage.

Here's an example usage:

export class ImportGuestResolver {
class: "ImportGuestResolver",
async: true,
type: Event,
args: [
name: "eventID",
type: GraphQLID,
name: "file",
type: gqlFileUpload,
async importGuests(
context: RequestContext,
eventID: ID,
file: Promise<FileUpload>,
) {

leads to this schema:

type Mutation {
importGuests(eventID: ID!, file: Upload!): Event!

Note this requires to developer to manually run npm install graphql-upload to use this.