Closed ssukienn closed 3 years ago
It seems the complexity and source of your problems is Nest, Apollo Server and Gateway; it's better to ask for help from the Nest community or Apollo customer service if you're having difficulty with their products.
Note that for schema stitching some of the tooling that might be present in your project substitutes the GraphQLUpload
scalar, because the original scalar is only intended as an input, but they "serialize" (even though a file upload stream can't be serialized to a string like the GraphQL serialization system was originally intended) the value back out to forward it to the next GraphQL API:
There is past discussion on this topic you can see in https://github.com/jaydenseric/graphql-upload/issues/194 .
Although everything about graphql-upload
is documented quite thoroughly in the readme, I'm happy to answer here any questions you may have about just the graphql-upload
project.
Hi. I have some problems with the structure of the uploaded file(s).
I integrated this library inside my federated project, the gateway, and example service. On top of that I am using Nest.js framework which is instantiating both mentioned above.
In both services, I turned off the default upload (in
ApolloGateway
andApolloServer
) by settinguploads: false
. Additionally, I set thegraphqlUploadExpress
middleware:My service federated schema related to uploads looks like:
and resolver:
Nest reference: https://github.com/nestjs/graphql/issues/901#issuecomment-780007582
UploadModel
is some input object which takes a file but it doesn't matter if the file is nested inside the input or passed as a direct argument. The actual file containingcreateReadStream
is obtained after some promise shenanigans happening inresolveFile
helper.When looking inside the debugger the actual structure of the
attachment
is something like: where I haveUpload
object withfile
property without the stream and thepromise
which when awaited consists of{ resolve, reject, promise}
and after awaiting this second promise (which I thought won't be there and I will get the file thus typing inresolveFile
) I actually get the real structure ofFileUpload
. Thefile
object from the screen on the same level asresolve
andreject
is not actually there until awaiting the second promise (that's why double promise awaits inresolveFile
).Unfortunately, it will be hard for me to provide some reproducible repo due to the size of the project but maybe someone faced similar issues with strange wrapping and have an idea of what I am doing wrong here?
I am testing it with the Altair with request source like:
Thanks for help.
versions:
graphql-upload: 12.0.0 @types/graphql-upload: 8.0.5