{"action":"created","issue":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/1052","repository_url":"https://api.github.com/repos/apollostack/apollo-client","labels_url":"https://api.github.com/repos/apollostack/apollo-client/issues/1052/labels{/name}","comments_url":"https://api.github.com/repos/apollostack/apollo-client/issues/1052/comments","events_url":"https://api.github.com/repos/apollostack/apollo-client/issues/1052/events","html_url":"https://github.com/apollostack/apollo-client/issues/1052","id":196132845,"number":1052,"title":"Update reducer is not firing","user":{"login":"0x6e6562","id":14088,"avatar_url":"https://avatars.githubusercontent.com/u/14088?v=3","gravatar_id":"","url":"https://api.github.com/users/0x6e6562","html_url":"https://github.com/0x6e6562","followers_url":"https://api.github.com/users/0x6e6562/followers","following_url":"https://api.github.com/users/0x6e6562/following{/other_user}","gists_url":"https://api.github.com/users/0x6e6562/gists{/gist_id}","starred_url":"https://api.github.com/users/0x6e6562/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0x6e6562/subscriptions","organizations_url":"https://api.github.com/users/0x6e6562/orgs","repos_url":"https://api.github.com/users/0x6e6562/repos","events_url":"https://api.github.com/users/0x6e6562/events{/privacy}","received_events_url":"https://api.github.com/users/0x6e6562/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-12-16T19:09:55Z","updated_at":"2016-12-23T09:38:08Z","closed_at":null,"body":"I'm trying to get an [update reducer](http://dev.apollodata.com/react/cache-updates.html#resultReducers) to fire upon a successful mutation. However the reducer does not appear to get triggered, even though the round trip to the server was successful.\r\n\r\nThis is how I configured the reducer:\r\n\r\n```js\r\nconst ReducerTestWithData = compose(\r\n  graphql(UpdateValueMutation, {\r\n    props: ({ mutate }) => ({\r\n      updateValue: (id, value) => mutate({ variables: {id, value} })\r\n    }),\r\n    options: (ownProps) => ({\r\n      reducer: (prev, action) => {\r\n        console.log(\"Reducer fired\");\r\n        return prev;\r\n      }\r\n    }),\r\n  }),\r\n  connect(\r\n    (state, ownProps) => ({}),\r\n    (dispatch, ownProps) => ({\r\n      dispatch,\r\n    }),\r\n  ),\r\n)(ReducerTest);\r\n```\r\n\r\nI'm wondering if there's any extra configuration (for example when setting up the store) that I've missed, or is maybe the `options` stanza wrong?\r\n\r\nI've stripped the example down to a bare bones runnable example (see below). In this example, the update is successful, but the reducer does not fire:\r\n\r\n```js\r\nimport React, { Component, PropTypes } from 'react';\r\nimport {\r\n  AppRegistry,\r\n  StyleSheet,\r\n  Text,\r\n  View,\r\n  TouchableOpacity\r\n} from 'react-native';\r\n\r\nimport { createStore, combineReducers, applyMiddleware} from 'redux';\r\nimport ApolloClient, { createNetworkInterface } from 'apollo-client';\r\nimport { ApolloProvider, graphql, compose } from 'react-apollo';\r\nimport { connect } from 'react-redux';\r\nimport gql from 'graphql-tag';\r\n\r\nconst styles = StyleSheet.create({\r\n  container: {\r\n    flex: 1,\r\n  },\r\n});\r\n\r\nclass ReducerTest extends Component {\r\n\r\n  constructor(props) {\r\n    super(props);\r\n    this.updateValue = this.updateValue.bind(this);\r\n  }\r\n\r\n  updateValue() {\r\n    this.props.updateValue(\r\n      \"101\",\r\n      \"some_value\"\r\n    ).then(({ data }) => {\r\n      if (!data.errors) {\r\n\r\n        let { id, value } = data.updateValue;\r\n        console.log(\"Successfully updated value (\" + value + \") for id (\" + id +\")\");\r\n\r\n      } else {\r\n        console.log(\"Application error: \" + error);\r\n      }\r\n    }).catch((error) => {\r\n      console.log(\"Server error: \" + error);\r\n    });\r\n  }\r\n\r\n  render() {\r\n    return (\r\n      <View style={{alignItems: 'center', justifyContent: 'center', flex: 1}}>\r\n        <TouchableOpacity onPress={this.updateValue}>\r\n          <Text>UPDATE VALUE</Text>\r\n        </TouchableOpacity>\r\n      </View>\r\n    );\r\n  }\r\n}\r\n\r\nReducerTest.propTypes = {\r\n  updateValue: PropTypes.func.isRequired,\r\n};\r\n\r\nconst UpdateValueMutation = gql`\r\n  mutation updateValue($id: String!, $value: String!) {\r\n    updateValue(id: $id, value: $value) {\r\n      id\r\n      value\r\n    }\r\n  }\r\n`;\r\n\r\nconst ReducerTestWithData = compose(\r\n  graphql(UpdateValueMutation, {\r\n    props: ({ mutate }) => ({\r\n      updateValue: (id, value) => mutate({ variables: {id, value} })\r\n    }),\r\n    options: (ownProps) => ({\r\n      reducer: (prev, action) => {\r\n        console.log(\"Reducer fired\");\r\n        return prev;\r\n      }\r\n    }),\r\n  }),\r\n  connect(\r\n    (state, ownProps) => ({}),\r\n    (dispatch, ownProps) => ({\r\n      dispatch,\r\n    }),\r\n  ),\r\n)(ReducerTest);\r\n\r\nclass ReducerTestContainer extends Component {\r\n\r\n  constructor(props) {\r\n    super(props);\r\n    const networkInterface = createNetworkInterface({ uri: 'http://localhost:4000/api' });\r\n\r\n    this.client = new ApolloClient({\r\n      networkInterface,\r\n      dataIdFromObject: (result) => {\r\n        if (result.id && result.__typename) {\r\n          return result.__typename + result.id;\r\n        }\r\n        return null;\r\n      },\r\n    });\r\n\r\n    this.store = createStore(\r\n      combineReducers({\r\n        apollo: this.client.reducer(),\r\n      }),\r\n      compose(\r\n        applyMiddleware(this.client.middleware()),\r\n      )\r\n    );\r\n  }\r\n\r\n  render() {\r\n    return (\r\n      <ApolloProvider store={this.store} client={this.client}>\r\n        <ReducerTestWithData/>\r\n      </ApolloProvider>\r\n    );\r\n  }\r\n}\r\n\r\nAppRegistry.registerComponent('reducer_test', () => ReducerTestContainer);\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/comments/268963699","html_url":"https://github.com/apollostack/apollo-client/issues/1052#issuecomment-268963699","issue_url":"https://api.github.com/repos/apollostack/apollo-client/issues/1052","id":268963699,"user":{"login":"luckyyang","id":1963646,"avatar_url":"https://avatars.githubusercontent.com/u/1963646?v=3","gravatar_id":"","url":"https://api.github.com/users/luckyyang","html_url":"https://github.com/luckyyang","followers_url":"https://api.github.com/users/luckyyang/followers","following_url":"https://api.github.com/users/luckyyang/following{/other_user}","gists_url":"https://api.github.com/users/luckyyang/gists{/gist_id}","starred_url":"https://api.github.com/users/luckyyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luckyyang/subscriptions","organizations_url":"https://api.github.com/users/luckyyang/orgs","repos_url":"https://api.github.com/users/luckyyang/repos","events_url":"https://api.github.com/users/luckyyang/events{/privacy}","received_events_url":"https://api.github.com/users/luckyyang/received_events","type":"User","site_admin":false},"created_at":"2016-12-23T09:38:08Z","updated_at":"2016-12-23T09:38:08Z","body":"tested at version `2.5.24`, will not trigger the updateQueries"}}
{"actor":{"display_login":"luckyyang"}}