Closed francelwebdev closed 2 years ago
The way the graphql-upload
API is being used doesn't look right. I'm not sure what the .value
is that you're awaiting, but an Upload
scalar when awaited shouldn't resolve the Upload
class like that. That class is an internal graphql-upload
implementation detail you shouldn't be exposed to in resolvers. Maybe graphql-upload
hasn't been installed properly, or there are multiple installations of different versions conflicting?
Thank you for your quick reply. Here is the content of the server file.
And here is the top of the resolvers file.
And here is the end of the resolvers file.
when i submit the form with the images attached, here is what i have in the browser console.
And in the terminal this is what I have.
As you can see from the images, only one file was solved, the others were not solved while everything has to be solved so that I can send the files to s3.
From memory buildSchema
from GraphQL.js is not able to handle custom scalars, in this case GraphQLUpload
from graphql-upload
. I'm not sure this is the best link I can find on the topic, but here is a relevant StackOverflow question and answer: https://stackoverflow.com/questions/47824603/graphql-custom-scalar-definition-without-graphql-tools .
Most people who like to use a big GraphQL SDL string to design the schema and merge it with implementation code use third party libraries to do it. I really, really recommend just using pure JavaScript and GraphQL.js to define your schema. It's much more efficient, requires no third party libraries, and allows you to modularise it very easily using basic JS modules. You can also dynamically code details of the types, e.g. use a template string to create a type description.
Thank you again for your help. I was using the graphql js package directly, then I'm going to remove the package and use graphql-tool. thanks again.
Glad to have helped :)
I have the same issue but I can not found the solution, can you help me?
This is resolver
I am using "graphql-upload": "^15.0.2" + "@types/graphql-upload": "^15.0.2"
import { PathLike, createWriteStream } from 'node:fs'; import { mkdir, stat } from 'node:fs/promises'; import path from 'node:path';
import { Logger, UseGuards } from '@nestjs/common'; import { Args, Context, Info, Mutation, Parent, Query, ResolveReference, Resolver, } from '@nestjs/graphql'; import { GraphQLResolveInfo } from 'graphql'; import gql from 'graphql-tag'; import GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
import { CaslSubject, GqlCaslGuard } from '../../auth'; import { PrismaSelectArgs } from '../../prisma'; import type { Upload } from '../models'; import { IContext } from '../models'; import resolvers from '../paljs/File/resolvers'; import type { Auth_AggregateFileArgs, Auth_CreateOneFileArgs, Auth_DeleteManyFileArgs, Auth_DeleteOneFileArgs, Auth_FindFirstFileArgs, Auth_FindFirstFileOrThrowArgs, Auth_FindManyFileArgs, Auth_FindUniqueFileArgs, Auth_FindUniqueFileOrThrowArgs, Auth_UpdateManyFileArgs, Auth_UpdateOneFileArgs, Auth_UpsertOneFileArgs, } from '../resolversTypes';
Hello, I have a problem when i upload multiple files, i don't know why all the promises are not resolved. Please help me. When I upload a single file the promise is resolved well and I can upload the file to an S3 service, but when I upload multiple files, say 3 or 4 files, only one or two file is resolved and everything else is pending.
Here is what I have in the terminal
Here is the code