Member-only story
Note: The code mentioned in this post can be found in these repositories.
NestJS Reference — @mrsauravsahu/blog-graphql-nestjs-fileupload
.NET Reference — @mrsauravsahu/blog-graphql-dotnet-fileupload
GraphQL has become quite popular due to its various features fixing under/over fetching issues. It also allows for easy caching, federation, non-versioning APIs, subscriptions etc,.
For the modern Internet where data needs to be accessible on various types of applications running on various types of devices, GraphQL seems like a great way forward and also a good concept to put into your knowledge bag.
What are we trying to do?
GraphQL request and responses are typically in JSON format even though the GraphQL Spec doesn’t mandate any format.
All data fetching and uploading can be done easily with GraphQL and responses can also use GZIP for compression.
One thing GraphQL lacks (or rather doesn’t have a standard implementation for) is File Uploads.
Why/Why not?
There’s no right or wrong here, but here are a few things to consider when you want to have file uploads and you also have a GraphQL API.