2

i was trying to upload file to my apollo server but i can't upload any file and it does not throw any error but i receive only empty object in resolver and it works find when i use GraphQL Client like Altair

output in server when using Altair Client

{
    filename: 'Copy of Massive Orange Summer Sale Animated-300x250px-MediumRectangle.png',
    mimetype: 'image/png',
    encoding: '7bit',
    createReadStream: [Function: createReadStream]
}

output in server when using @apollo/client package

{}

client code

client code

server code

server code

2
  • 8
    Please do not post images of code. Commented Dec 27, 2020 at 15:06
  • 1
    @peace please share code instead of image link Commented Dec 28, 2020 at 6:28

1 Answer 1

6

Uploads are not supported in Apollo Client by default. If you want to enable them, you need to use createUploadLink from apollo-upload-client as shown here.

import { createUploadLink } from 'apollo-upload-client';

const client = new ApolloClient({
  cache: new InMemoryCache(),
  link: createUploadLink(),
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.