21

Im trying to figure out how to use apollo-link-http with apollo-upload-client.

Both create a terminating link, but how could I use those 2 together? In my index.js I have like this, but it wont work because both links are terminating =>

const uploadLink = createUploadLink({ uri: process.env.REACT_APP_GRAPHQL_URL });

const httpLink = new HttpLink({ uri: process.env.REACT_APP_GRAPHQL_URL });

const client = new ApolloClient({
    link: ApolloLink.from([ authLink, logoutLink, stateLink, uploadLink, httpLink ]),
    cache,
});

Any help? I have not much experience with Apollo/Graphql, but I would like to use the file upload component.

Jack M.
  • 1,831
  • 5
  • 24
  • 36

1 Answers1

40

You do not need the http link if you use apollo-upload-client with version higher than 6.

You can try like this:

const uploadLink = createUploadLink({ uri: process.env.REACT_APP_GRAPHQL_URL });

const client = new ApolloClient({
    link: ApolloLink.from([ authLink, logoutLink, stateLink, uploadLink ]),
    cache,
});
Henry Woody
  • 14,024
  • 7
  • 39
  • 56
Locco0_0
  • 3,420
  • 5
  • 30
  • 42