jaydenseric / graphql-multipart-request-spec

A spec for GraphQL multipart form requests (file uploads).
993 stars 54 forks source link

createReadStream is not a function #39

Closed Thando-James closed 3 years ago

Thando-James commented 3 years ago

Hi I'm trying to upload a file using GraphQL and I'm getting the following error

Error: GraphQL error: createReadStream is not a function
    at new ApolloError (bundle.esm.js:63)
    at Object.next (bundle.esm.js:1004)
    at notifySubscription (Observable.js:135)
    at onNotify (Observable.js:179)
    at SubscriptionObserver.next (Observable.js:235)
    at bundle.esm.js:866
    at Set.forEach (<anonymous>)
    at Object.next (bundle.esm.js:866)
    at notifySubscription (Observable.js:135)
    at onNotify (Observable.js:179)

The following is my mutation

mutation UploadProfile($file: Upload!) {
  upload(file: $file) {
    id
  }
}

And the following is how I post my image

client.mutate<UploadProfile, UploadProfileVariables>({
        mutation: UploadProfileMutation,
        variables: {
          file: profileProperties.file,
        },
        context: {
          headers: {
            Authorization: `Bearer ${token}`,
          },
        },
      })

I don't know why it's not working and I'm not finding the solution on the internet. Please help

Thando-James commented 3 years ago

I solved it. I was supposed to use the createUploadLink from the apollo-upload-client package instead of the Httplink