awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
920 stars 266 forks source link

fix: using apollo core to avoid loading react #613

Closed clemkoa closed 2 years ago

clemkoa commented 3 years ago

Issue: https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/611

Description of changes: As described in the issue, the apollo client loads react by default which is not optimal. Instead of using @apollo/client I import @apollo/client/core which is just the apollo functions needed!

The apollo team described the migration process on this page: https://www.apollographql.com/docs/react/migrating/apollo-client-3-migration/ . They use the package @apollo/client because they are in a react project. As described here https://www.apollographql.com/docs/react/migrating/apollo-client-3-migration/#using-apollo-client-without-react, "Apollo Client 3.0 includes built-in support for React hooks, but it absolutely still supports non-React view layers. To use Apollo Client 3.0 with Vue, Angular, or another view layer of your choosing, import ApolloClient from the @apollo/client/core entry point". Importing @apollo/client/core works with all js frameworks and doesn't force react to be loaded.

Happy to modify if you have feedback

clemkoa commented 3 years ago

Hi, is there anything holding back this PR? Do you need more information?

fsproru commented 3 years ago

Having the same issue too, here is another PR fixing the same issue: https://github.com/awslabs/aws-mobile-appsync-sdk-js/pull/599

@manueliglesias @elorzafe @dabit3 is there a way to get this fix in?

aradalvand commented 3 years ago

Will this PR be merged? It's been 2 months.

clemkoa commented 3 years ago

@elorzafe can you please check out this PR? The wrong imports break a lot of non-react ts projects

pmuller commented 3 years ago

Same issue here. I'd be happy to see this PR get merged. :)

DregondRahl commented 3 years ago

Looking forward to this merge. Would help alot with use Vue for AppSync

viktormuller commented 3 years ago

Looking forward to this merge. It would reduce significantly the dependencies of our AWS Lambda and hence its cold start time.

revmischa commented 2 years ago

Unfortunately AWS employees get raises and promotions for shipping new features and services but not for maintaining anything. We see the limitations of this approach to incentivizing employees here.

sammartinez commented 2 years ago

Apologizes folks for missing this! I do have some people looking into this now. Thanks for raising this up @revmischa