cleverbeagle / pup

The Ultimate Boilerplate for Products.
https://cleverbeagle.com/pup
554 stars 139 forks source link

Apollo version and hooks #356

Open steinitz opened 3 years ago

steinitz commented 3 years ago

Hi,

Thanks again for sharing Pup. It's awesome and continues to stands alone in providing this breadth of full-stack superpowers. I was pleased to discover that you intend to continue work on Pup, including an upgrade to Meteor 2. Bravo.

On the topic of upgrades, I'm in the middle of upgrading Apollo, in Pup, to allow use of the useMutation hook and its friends. I'm stuck in module hell and a bit overwhelmed.

I'd enjoy hearing from anyone who has gone down this Apollo upgrade path or has an interest in it.

cleverbeagle commented 3 years ago

@steinitz can you share more details about what errors you're running into?

steinitz commented 3 years ago

Thanks for your reply @cleverbeagle

I was able to solve the build and runtime issues - the app works again. I haven't yet replaced the Mutation component with useMutation but I now have recent Apollo libs. Here they are:

"@apollo/client": "^3.3.13",
"@apollo/react-components": "^4.0.0",
"apollo-cache-inmemory": "^1.6.6",
"apollo-link": "^1.2.14",
"apollo-link-error": "^1.1.13",
"apollo-link-http": "^1.5.17",
"apollo-server-express": "^2.22.2",

notes: I was able to remove react-apollo and others I didn't manually set versions I haven't confirmed they're all required

The conversion required a couple dozen minor changes to imports. Here are some highlights:

Importing compose and graphql is now done so:

import {graphql} from '@apollo/client/react/hoc';
import {flowRight as compose} from 'lodash'; // apollo no longer keeps a copy of flowRight named compose

Here are some other changed imports:

import { renderToStringWithData } from '@apollo/client/react/ssr';
import { ApolloProvider } from '@apollo/client'

I hope this helps somebody get over the hump, or at least know it's feasible.