I recently started using GraphQL with Apollo for small projects to understand how it works and what are some of the shortfalls of using it.

If you don’t know what is GraphQL, I recommend you to have a read at http://graphql.org/learn/ (this is my GraphQL go to Manual).

In a nutshell, GraphQL is an extremely flexible query language developed by Facebook. Similar to REST, it sits between your frontend and backend.

source: Apollo Data

It wasn’t too long until I started adopting GraphQL into more complex projects such as an e-commerce. In GraphQL you have essentially three core aspects: Schemas, Resolvers and Mutations.

Schemas: Define the blueprint of your data

Resolvers: Defines how your data is retrieved from the store

Mutations: Defines the way your data gets changed.

Once you piece all of these together you end up with a layer that handles the different operations on your data. As my projects are React based, I chose to use react-apollo as the documentation was pretty simple to understand and it has numerous examples (big plus).

Today, I stumbled on a use case where I had to upload a picture together with form data. For people who are not aware, apollo-client communicates to the graphql-server only through application/json making file transfer a no go.

I was sure there was a way to overcome this, note this was not a limitation of GraphQL server, but instead of the library I chose to interface with it . In this case Apollo Client. After digging through the github, I stumbled on this thread: https://github.com/apollographql/apollo/issues/65 soon enough a package (apollo-upload-server) was created precisely to preprocess the file data as a multipart/form-data which allowed the GraphQL to consume and handle it.

After implementing apollo-upload-server into my project, I could easily submit a picture and handle it in my mutation function which uploads to Amazon S3. So far, I think GraphQL is still growing but it already provides more than sufficient features for any complex projects you might have.

If there is interest, I can create a series to explain step by step how to set up a project using GraphQL and upload an image to Amazon S3.

Special thanks to @jaydenseric for coming up with Apollo Upload server!