Track subscription last result to help avoid extra renders
Track subscription last result to help avoid extra renders

In the `Query` component, we’re watching for any data that comes
in through the Apollo Client `watchQuery` Observable (started in
`startQuerySubscription`). When new data is received via the
Observable subscription, we’re calling `React.forceUpdate` to
force a re-render of the component, so it can use the the new data.

While this works, the problem with this approach is that we’re
forcing a re-render of the component every time a new result
comes in through the subscription (excluding a small check to
avoid an initial re-render when getting the component ready),
even if the component is already in a state that matches the state
it would be put into, after using the result that just came in
from the subscription. This can lead to unnecessary re-renders.

This problem has always been lurking in React Apollo, but has
become more evident due to changes made in Apollo Client 2.5.0.

This commit updates React Apollo to keep track of the last
result that was received in an Observble subscription chain,
and will compare the latest incoming result against this last
result, before deciding if the component should be `forceUpdate`d.

apollostack/react-apollo,apollographql/react-apollo,apollographql/react-apollo,apollostack/react-apollo