1

I need to upload multiple images using a single graphql mutation.

Following official nexus documentation, I managed to use graphql-upload library and got access to upload scalar type as below,

import { GraphQLUpload } from "graphql-upload";
import { asNexusMethod } from "nexus";

export const Upload = asNexusMethod(GraphQLUpload, "upload");

Single upload - working

import { inputObjectType } from "nexus";

export const ProductCreateInputOverride = inputObjectType({
  name: "ProductCreateInputOverride",
  definition(t) {
    t.upload("images");
  }
});

Multiple upload - not working

import { inputObjectType } from "nexus";

export const ProductCreateInputOverride = inputObjectType({
  name: "ProductCreateInputOverride",
  definition(t) {
    t.list.upload("images");
  }
});

When using t.list.upload("images"), typescript is not showing any errors and gives auto-completion also. But the server start will fail with error "t.list.upload" is not a function.

Is this not the right way to do it ???. Please suggest.

Suneeth Lenin
  • 285
  • 1
  • 4
  • 10

1 Answers1

1

I found out the reason. This is a bug in current nexus release and is already being addressed. Please find the pull request link below

https://github.com/prisma/nexus/pull/141

Suneeth Lenin
  • 285
  • 1
  • 4
  • 10