Non-tech founder’s guide to choosing the right software development partner Download Ebook
Home>Blog>Graphql files upload testing

Graphql files upload testing

Graphql is not very convenient when it comes to uploading files, but it is possible, for example, gem apollo-upload-server-ruby  is often used for this purpose.

To check file uploads with apollo-upload-server-ruby, I recommend using Altair GraphQL Client it allows you to easily upload files, unlike more well-known competitors such as insomnia.

Unit-testing file uploads with apollo-upload-server-ruby is not very obvious either, by examining the source code of the apollo-upload-server-ruby gem I found that in order for apollo-upload-server-ruby to properly respond to an uploaded file, the following code must be used:

 RSpec.describe Mutations::YourMutation, type: :mutation do

  subject { YourSchema.execute(query, variables: graphql_variables).as_json }

let(:uploaded_file) {'spec/fixtures/files/test.png') }

let(:graphql_variables) { { image: image } }

  let(:image) do

        tempfile: uploaded_file, filename: File.basename(uploaded_file),

        type: 'image/png'




  def query


       mutation YourMutation($image: Upload!) {

        images(input: { image: $image }) {

          image {







Happy Testing!

Discover More Reads

Real Stories & Real Success

Do you have a tech idea?

Let’s talk!

By submitting this form, you agree with JetRockets’ Privacy Policy

If you prefer email, write to us at