graphql-request icon indicating copy to clipboard operation
graphql-request copied to clipboard

ReactNative upload file

Open 6youss opened this issue 2 years ago • 1 comments

I see that the docs mention Upload in Browser and Node.

Does graphql-request support uploading files in react-native ?

6youss avatar Nov 12 '21 02:11 6youss

i just figured it out, yes it supports it and it goes like this :

import { ReactNativeFile } from 'extract-files';

const mutation = gql`
  mutation uploadFile($file: Upload) {
    uploadFile(file: $file)
  }
`;

graphQLClient.request(mutation, {
      file: new ReactNativeFile({ uri, type, name }),
});

6youss avatar Nov 12 '21 02:11 6youss

This does not seem to work for me

zdnk avatar Apr 03 '23 14:04 zdnk

https://github.com/jasonkuhrt/graphql-request/issues/500

jasonkuhrt avatar Apr 05 '23 12:04 jasonkuhrt

I see, we had to switch to apollo due to this :(

zdnk avatar Apr 05 '23 13:04 zdnk