I am new to react with graphql.
I want to upload .pdf file to server via network interface.
All I need to do is write a graphql query using apollo client which sends multipart form data to server.
I tried to search it on google but I did't found any proper solution.
mutation createUser($user: myfile) {
createData(myfile: $user) {
id
name
email
}
}
I am new to react with graphql.
I want to upload .pdf file to server via network interface.
All I need to do is write a graphql query using apollo client which sends multipart form data to server.
I tried to search it on google but I did't found any proper solution.
mutation createUser($user: myfile) {
createData(myfile: $user) {
id
name
email
}
}
Share
Improve this question
edited Apr 14, 2017 at 13:55
Mohammad Akbari
4,7846 gold badges51 silver badges78 bronze badges
asked Apr 14, 2017 at 12:27
Tejas SatheTejas Sathe
511 gold badge1 silver badge2 bronze badges
1 Answer
Reset to default 6GraphQL doesn't normally deal with multipart data or file uploads, but if you are writing your server yourself you can create a custom request type which has more fields than just the query
, and thus make it work. This guy did it here.
This is a rather roundabout way to go at it which will probably give you lots of headaches. I would remend being less stubborn about the single endpoint, and use a different server to manage the upload. After all, there are lots of well tested libraries dealing with all "the devils details" surrounding uploads.