Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

errorPolicy: all in defaultOptions causes error to be undefined #2253

Closed
adrienharnay opened this issue Aug 6, 2018 · 2 comments
Closed

Comments

@adrienharnay
Copy link

Intended outcome:

Trying to define errorPolicy: all in ApolloClient defaultOptions.

Actual outcome:

errorPolicy: all causes error in <Mutation>{(func, { error }) => <SomeComponent />}</Mutation> to always be undefined.

Screen 1
Screen 2

const client = new ApolloClient({
  defaultOptions: {
    watchQuery: {
      fetchPolicy: 'cache-and-network',
      // errorPolicy: 'all',
    },
    query: {
      fetchPolicy: 'cache-and-network',
      // errorPolicy: 'all',
    },
    // mutate: {
    //   errorPolicy: 'all',
    // },
  },
});

Commenting it makes errors appear again.

<Mutation errorPolicy="all">{(func, { error }) => <SomeComponent />}</Mutation>

Specifying it at Mutation level, and not glabally, also works.

How to reproduce the issue:

const client = new ApolloClient({
  defaultOptions: {
    watchQuery: {
      fetchPolicy: 'cache-and-network',
      errorPolicy: 'all',
    },
    query: {
      fetchPolicy: 'cache-and-network',
      errorPolicy: 'all',
    },
    mutate: {
      errorPolicy: 'all',
    },
  },
});

when declaring the client, and then performing a mutation with an error.

Version

Thanks in advance!

@amacleay
Copy link
Contributor

I made a branch to demonstrate this issue in react-apollo-error-template in case it's helpful.

I do believe #2297 would resolve this issue.

This was referenced Sep 10, 2018
@adrienharnay
Copy link
Author

Yes it seems like it did! Thanks for your help on this 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants