Skip to content

Fetch errors not working correctly with the useMutation React hook #222

@Densz

Description

@Densz

When I use createUploadLink in my React app

const httpLink = createUploadLink({
  uri: 'http://localhost:4000/graphql"',
});

const client = new ApolloClient({
  link: from([authMiddleware, httpLink]),
  cache: new InMemoryCache(),
});

I cannot catch errors thrown by Mutations using useMutation()

const onSubmit = (data) => {
    mutationLogin({ variables: data })
      .then // it works when the mutation doesn't throw
      .catch // never goes in it even when the mutation throw

And on the browser console I get the error below

createUploadLink.js:148 Fetch failed loading: POST "http://localhost:4000/graphql".

And when use HttpLink from @apollo/client it works perfectly fine

const httpLink = new HttpLink({
  uri: 'http://localhost:4000/graphql"',
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions