Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to send multipart request #132

Closed
mayankpandav opened this issue Apr 15, 2019 · 19 comments
Closed

how to send multipart request #132

mayankpandav opened this issue Apr 15, 2019 · 19 comments

Comments

@mayankpandav
Copy link

how we can upload files through mutation ?

@ferso
Copy link

ferso commented Jun 18, 2019

I need this too...

@mayankpandav
Copy link
Author

mayankpandav commented Jun 21, 2019

Hello you can send multipart request using below method via Postman

First You have to define your type with GraphqlScalar E.G,
const GraphQLProfilePic = new GraphQLScalarType({
name: 'profilePic',
parseValue: value => value,
parseLiteral() {
throw new Error('‘Upload’ scalar literal unsupported.')
},
serialize() {
throw new Error('‘Upload’ scalar serialization unsupported.')
},
})

**{
query: mutation($file: Upload!) { uploadFile(file: $file) { id } },
variables: {
file: File // a.txt
}
}
**

First Field

{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }
Second Field
{ "0": ["variables.file"] }
Third Field
file where you can use choose file from dropdown instead choosing text field .

@ferso
Copy link

ferso commented Jun 23, 2019

This works for me

@mayankpandav
Copy link
Author

good ....

@eduarddotgg
Copy link

any better example? documentation?

@mayankpandav
Copy link
Author

@iamfrntdv you can see request format here https://github.com/jaydenseric/graphql-multipart-request-spec

@nagman
Copy link

nagman commented Sep 2, 2019

@ferso What do you mean by "This works for me"? What did you implement?

@mayankpandav We're talking about passing multipart data through graphql-request. Why are you talking about Postman?

Now the real question is: How can we implement a multipart request with graphql-request?

@mayankpandav
Copy link
Author

@nagman are you talking about client side or server side?

@nagman
Copy link

nagman commented Sep 3, 2019

@mayankpandav Client. graphql-request is a GraphQL client.

@nagman
Copy link

nagman commented Sep 3, 2019

@mayankpandav Yet we're on the graphql-request package. Why would you share something from relay-runtime?

I don't understand the point with this topic.

@jonaskello
Copy link

I too would like to see file upload support in graphql-request using the multipart specification. Is this issue about that and if so why is it closed? AFAIK multipart support is not implemented in graphql-request.

@talzion12
Copy link

Why is this closed?

@jonaskello
Copy link

You might want to try this package: https://github.com/dividab/graphql-simple-fetch

@dsbrgg
Copy link

dsbrgg commented Mar 2, 2020

Bump for this.

I think this feature would be great as well, I'm proxying graphql requests and this was the only feature left to make it complete.

@pfalomorblab
Copy link

it would be great to have this

@lynxtaa
Copy link
Contributor

lynxtaa commented Jul 12, 2020

I've created PR to solve this issue #175

@lynxtaa
Copy link
Contributor

lynxtaa commented Jul 20, 2020

Meanwhile I've published https://www.npmjs.com/package/awesome-graphql-client with GraphQL Upload support in NodeJS and browsers which also solves #61 and #10
Hope you enjoy!

@jasonkuhrt jasonkuhrt reopened this Aug 19, 2020
@warent
Copy link

warent commented Aug 24, 2020

Thanks @lynxtaa, exactly what I needed

@jasonkuhrt
Copy link
Member

#500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests