Migrate from Apollo Boost to a custom Apollo Client setup for more flexibility, including authentication. Learn how to create middleware for auth, and understand potential CORS issues.
If you have been using ApolloClient in your projects, you have probably started using their "apollo-boost" package. And for starting this is the right approach, but the limitations of that setup appear very quickly when working on a production application. Something as simple as using a graphQL server that requires authentication causes a steep learning curve into the inner workings of ApolloClient. My goal is to point out some of the stumbling blocks I have been encountering and the links to the solutions or articles that helped me.
The Migration: If you'd like to use subscriptions, swap out the Apollo cache, or add an existing Apollo Link to your network stack that isn't already included, you will have to set Apollo Client up manually. Their guide (https://www.apollographql.com/docs/react/migrating/boost-migration/) is very well written. This will help you get the right packages installed in your project. However...
This setup for authentication may not work or give you the flexibility needed to tie to your backend server. A middleware function needs to be created (https://www.apollographql.com/docs/react/networking/network-layer/#middleware). A combination of those links will help you get a proper migration from boost to a real-world set up of ApolloClient. Bellow is what a completed set up will look like.