Skip to content
Trevor Casey edited this page Mar 5, 2018 · 1 revision

Apollo Refetch

If you get an error when trying to use refetch that looks something like this:

One of the sources for assign has an enumerable key on the prototype chain. Are you trying to assign a prototype property?

The refetch function takes a single variables object argument as it's parameter, while react-native's onPress property passes a Proxy object to the listener callback passed to it.

meaning this will throw an error:

render() {
  const { data: { refetch } } = this.props;
  return (
    <TouchableOpacity onPress={ refetch }>
      <Text>Refetch</Text>
    </TouchableOpacity>
  );
}

And this will not:

render() {
  const { data: { refetch } } = this.props;
  return (
    <TouchableOpacity onPress={ () => refetch() }>
      <Text>Refetch</Text>
    </TouchableOpacity>
  );
}

The object assign being done inside of apollo's refetch causes the error to be thrown.

Clone this wiki locally