Basically, I have a upload query that is:
type CustomUploadStructure {
id: String!
upload: Upload!
}
mutation uploadMethod($accessKey: String, $uploadFiles: [CustomUploadStructure!])
From what i’ve seen, this can’t be done on iOS; but i’m looking for options.
What I was trying to do was to deconstruct the mutation obj array on and trying to rebuild it, but i believe I can’t do this with graphql alone.
mutation clientUploadMethod($accessKey: String, $uploadIds: [String!]!, $uploads: [Upload!]!) {
response: serverUploadMethod(
accessKey: $accessKey, $uploadFiles: { id: $uploadIds, upload: $uploads } # this gives error
)
}
Is there anything that can do done solve it on client side?
Hi @celtaheaven
- we generally don’t recommend using GraphQL for file uploads but we do have documentation that demonstrates how we support it - Mutations - Apollo GraphQL Docs. Honestly I’d look at using other means for the upload and use your mutation to set the location of where the files were uploaded to.
Thanks for the answer Calvin. Well, I’m asking my team to do accordingly with the docs as its possible.
But considering that it’s not a recommendation to upload directly from Apollo, I believe there should be a very explicit warning in the documentation, to aware this is not the recommended practice.
Still, thank you!
But considering that it’s not a recommendation to upload directly from Apollo
It’s not that Apollo iOS is the problem. Uploading via GraphQL is a terrible workflow and there are better solutions.
I believe there should be a very explicit warning in the documentation, to aware this is not the recommended practice.
The linked documentation opens with the text below, I think it’s a fair warning.
An Important Caveat About File Uploads
Apollo recommends only using GraphQL file uploading for proof-of-concept applications. While there is a spec we presently support for making multipart-form requests with GraphQL, we’ve found that, in practice, it’s much simpler to use more purpose-built tools for file upload.
Apollo recommends using more traditional methods to upload your files, such as REST multipart-form uploads or SDK’s that support file uploads, such as AmazonS3.
Hope you find a reliable solution that works for your project.