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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.