admin管理员组文章数量:1305364
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.
本文标签:
版权声明:本文标题:javascript - Is there any way to send multipart form request to graphql in reactjs with apollo client - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741805833a2398499.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论