Member-only story

File Uploads on GraphQL: Why or Why not

Sahu
7 min readNov 19, 2021

--

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

Moon (Made with Blender)
The Moon (Moon — Apollo — GraphQL, “get it? 😂”), made with Blender [@photosbysaurav on Instagram]

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.

--

--

Sahu
Sahu

Written by Sahu

All opinions shared are personal and not influenced by my Employer • Senior Software Engineer @ McKinsey & Company

No responses yet