jaydenseric / graphql-multipart-request-spec

A spec for GraphQL multipart form requests (file uploads).
993 stars 54 forks source link

‘operations’ multipart field #43

Closed kamalkech closed 3 years ago

kamalkech commented 3 years ago
import { Resolver, Args, Mutation } from '@nestjs/graphql';
import { GraphQLUpload } from 'apollo-server-express';
import { createWriteStream } from 'fs';
import { FileUpload } from 'graphql-upload';

@Mutation(() => Boolean)
  async uploadFile(
    @Args({ name: 'file', type: () => GraphQLUpload })
    { createReadStream, filename }: FileUpload,
  ): Promise<boolean> {
    return new Promise(async (resolve, reject) =>
      createReadStream()
        .pipe(createWriteStream(`./uploads/${filename}`))
        .on('finish', () => resolve(true))
        .on('error', () => reject(false)),
    );
  }

any idea ??

jaydenseric commented 3 years ago

Closing because this repo is for maintaining the spec itself, but this issue seems to be more of a request for help debugging your project.

Take a close look at the JSON you’re using in the operations field; it has some weird key and value stuff going on. Hope that helps!

kamalkech commented 3 years ago

Oh the field operations we have exactly what we found on your documentation (readme file), so i create this issue to make sure if i have a mistake or not, but i put 100% what i found on your documentation, so plz before close

Must to remove this plugins, bye

kamalkech commented 3 years ago

Find solution


@Mutation(() => Boolean)
  async uploadFile(
    @Args({ name: 'file', type: () => GraphQLUpload })
    { createReadStream, filename }: FileUpload,
  ): Promise<boolean> {
    const result: Promise<boolean> = new Promise(async (resolve, reject) =>
      createReadStream()
        .pipe(createWriteStream(`./uploads/${filename}`))
        .on('finish', () => resolve(true))
        .on('error', () => reject(false)),
    );
    return result;
  }
jaydenseric commented 3 years ago

i put 100% what i found on your documentation

No, you didn't. We can all see that you edited the issue description:

Screen Shot 2020-10-26 at 11 24 38 pm

Must to remove this plugins, bye

This repo is not a plugin, it's a specification used by many different GraphQL clients and servers.

I'm not sure why you seem to be upset; I helped you solve your problem 10 minutes after you raised the issue. What's more it's nearly midnight my time in Melbourne, Australia.

Anyway, glad you got it working.