react-apollo v4.0.0 Release Notes

  • 🗄 > ⚠️ Deprecation Notice ⚠️

    ⚡️ > Please note that as of version 4.0.0 you should prefer to import React hooks and testing utilities from @apollo/client. While we still have separate @apollo/react-hooks and @apollo/react-testing packages for ease of migration, they are no longer under active development, as they simply re-export from @apollo/client. React Apollo's graphql HOC (@apollo/react-hoc) and render proper components (@apollo/react-components) are in maintenance mode, meaning they will continue to receive important bug fixes, but will not be updated with new functionality.

    💥 Breaking Changes

    • React Apollo 4.0.0 only works with @apollo/client 3.x; it does not work with apollo-client 2.x. If you are using apollo-client and are not ready to update to @apollo/client, please use React Apollo 3.x.

    • ✅ Due to changes made in Apollo Client, the previous SSR testing pattern of:

      return getDataFromTree(app).then(() => {
        const markup = ReactDOM.renderToString(app);
        expect(markup).toMatch(/Waldo/);
      });
    

    will no longer work (ReactDOM.renderToString(app) will just return the initial loading state of the component under test). Instead, we can leverage the markup returned when getDataFromTree's Promise resolves:

      return getDataFromTree(app).then(markup => {
        expect(markup).toMatch(/Waldo/);
      });
    
    • 🏗 We are no longer building UMD versions of React Apollo.

    👌 Improvements

    • 📦 The React Apollo project now uses @apollo/client, which means it no longer houses Apollo's React hooks or testing utilities. @apollo/react-hooks and @apollo/react-testing can continue to be used, but their functionality is now re-exported from the @apollo/client package. If you're only using Apollo's React hooks, we recommend using @apollo/client directly, and dropping your dependency on @apollo/react-hooks.