Closed stemmlerjs closed 3 years ago
any update on this? are there any known implementations of the described flow supporting apollo?
We found that shipping a particular version of graphql-upload
along with Apollo Server (which we then couldn't upgrade past a certain point due to back-compat guarantees) was a bad pattern, so we are removing the direct upload integration from Apollo Server 3; integrating graphql-upload
with Apollo Server on the web frameworks they both support is relatively straightforward. So this sort of future improvement is best asked about on graphql-upload's repo.
Today, our documentation on File Uploads recommends uploading by piping file data through the GraphQL server to the application server. The main drawback of that approach is that it puts stress on the application server and might introduce more problems in production environments.
I just learned about this today from a conversation with @ThisIsMissEm on Spectrum, but Rails has this feature called active storage that facilitates uploading directly to either:
If, for example, you wanted to use AWS for Direct-to-Storage, we could enable users to configure
apollo-server
by hooking up anapollo-server-aws
Storage Adapter with their AWS creds, tell it the bucket name, and then expose a built-in type likeUploadToken
:The client would then need to perform two mutations. The first to request the signed URL to upload the file to, and the second to signal that the upload has been finished, allowing the application server to create any database records associated with the upload.
If we were to implement this, we could get started by defining some sort of
IStorageAdapter
and then implement it for the local filesystem, AWS, Google, Cloudinary, etc.