Company
Date Published
Author
Jens Neuse
Word count
3056
Language
English
Hacker News points
2

Summary

GraphQL file uploads can be a complex aspect of GraphQL Federation, but Cosmo makes it seamless with built-in support for storage providers like S3. The five most common approaches to upload files using GraphQL are: using GraphQL mutations with base64 encoded blobs, using GraphQL mutations with a multipart HTTP Requests, using a separate REST API, using S3, and WunderGraph's Approach using the TokenHandler Pattern with S3 as the storage. Before evaluating different solutions, it's essential to establish metrics for "good" solutions, including complexity of implementation on both client and server, bandwidth overhead, upload speed, portability, no vendor lock-in, security, and ease of implementing business logic after an upload is finished. The comparison of these options shows that base64 encoding files increases the size of the file by roughly one third, making it unsuitable for large files, while using a separate REST API or S3 can be clean solutions but may add complexity. The WunderGraph Approach using the TokenHandler Pattern with S3 as storage abstracts away the complexity from the developer and relies on open standards, offering a secure solution that balances between developer experience and flexibility without locking users into specific implementations.