title: Empty cache after server side rendering a request in isomorphic app using Apollo GraphQL and React
body: <p>I have a little problem with an isomorphic js application and maybe you can help me with this. I followed this tutorial: <a href="https://www.apollographql.com/docs/react/features/server-side-rendering.html" rel="nofollow noreferrer">https://www.apollographql.com/docs/react/features/server-side-rendering.html</a> regarding SSR and it basically works just fine. The initial request is rendered correctly, so this is fine. It’s the cache that gives me a headache… Whenever I call <code>client.extract()</code> it returns just an empty object, so my perfectly rendered page gets re-rendered as soon as the client code kicks in since the cache is empty. At this point I’m totally clueless as to why that doesn’t work. I even had a look at the Githunt example but the code in question is basically the same in my app, apart from differences in package versions.</p>
  
  <p>The stack I use:</p>
  
  <ul>
  <li>Docker composition with mongodb, graphql-server and isomorphic app</li>
  <li>Razzle as a framework for the isomorphic application</li>
  <li>Styled components</li>
  </ul>
  
  <p>The package versions:</p>
  
  <pre><code>"dependencies": {
      "apollo-cache-inmemory": "^1.2.5",
      "apollo-client": "^2.3.5",
      "apollo-link-http": "^1.5.4",
      "compression": "^1.7.2",
      "connect-mongo": "^2.0.1",
      "express": "^4.16.3",
      "express-session": "^1.15.6",
      "graphql": "^0.13.2",
      "graphql-tag": "^2.9.2",
      "isomorphic-fetch": "^2.2.1",
      "morgan": "^1.9.0",
      "razzle": "^2.2.0",
      "react": "^16.4.1",
      "react-apollo": "^2.1.8",
      "react-dom": "^16.4.1",
      "react-router-dom": "^4.3.1",
      "styled-components": "^3.3.3"
    }
  </code></pre>
  
  <p>Things I tried to fix the issue:</p>
  
  <ul>
  <li>Remove styled components</li>
  <li>Use <code>getDataFromTree</code> instead of <code>renderToStringWithData</code></li>
  <li>Remove docker composition and running it locally (Mac OS)</li>
  <li>Change package versions to the versions in the Githunt example</li>
  </ul>
  
  <p>The client initialization on the server:</p>
  
  <pre><code>const client = new ApolloClient({
        ssrMode: true,
        link: createHttpLink({
          uri: 'http://server:5000/graphql',
          fetch: fetch,
          credentials: 'include',
          headers: {
            cookie: req.header('Cookie'),
            origin: 'frontend:5000'
          },
        }),
        cache: new InMemoryCache()
      });
  </code></pre>
  
  <p>On client side the cache works just fine.</p>