Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphiQL - upload file

How can we upload files using in-browser GraphQL IDE GraphiQL, is that even possible ? (apart from base64 encoded string)

Once I have the file stream / file contents I can create a mulipart request and store on DB or some object-storage service. But I am not able to figure it out how to provide the file input / how the schema would look like. Is it better to use graphql-upload with Curl request. Please suggest which is the optimal solution.

like image 367
user2608576 Avatar asked Nov 23 '18 10:11

user2608576


People also ask

Can you upload files with GraphQL?

GraphQL Yoga supports GraphQL Multipart Request Specification which allows you to upload files via HTTP and consume the binary data inside GraphQL Resolvers.

How do I upload files to Altair?

Altair supports uploading both single files and an array of files (by switching the file upload from single to multiple file mode, or using the dot notation in single file mode e.g. for an array named fileList , you define the files as fileList. 0 , fileList. 1 , fileList.


2 Answers

I was able to upload a file in my mutation input using Altair. You can use the Add files button to upload a file, then use the upload name on your mutation.

enter image description here

like image 155
p8ul Avatar answered Sep 30 '22 02:09

p8ul


Guys just try Altair, saved me a lot of trouble and time. It has extension for chrome too, just like Apollo playground or graphiql, but with file upload option underneath the variables option.

like image 40
Amaar Hassan Avatar answered Sep 30 '22 02:09

Amaar Hassan