question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

apollo-client dependency is outdated; causes TypeScript errors

See original GitHub issue

I’m getting the following TS error:

ERROR in /Volumes/SuperData/Sites/reelcrafter/reelcrafter-ui/src/bootstrap/apollo.ts
20:3 Type 'AWSAppSyncClient<NormalizedCacheObject>' is missing the following properties from type 'ApolloClient<any>': clearStoreCallbacks, clientAwareness, stop, onClearStore
    18 |
    19 | export const apolloProvider = new VueApollo({
  > 20 |   defaultClient: client,
       |   ^
    21 | });
    22 |

AppSync works fine when it uses its own version of apollo-client that it depends on. But vue-apollo requires us to run yarn add apollo-client which installs a newer version that causes AppSync’s types to break.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
jgunninkcommented, May 29, 2019

Also had this problem. We resolved it by doing this. Yes it’s a hack, but at least you can get by until the issue is resolved. 😄

Given this appsync config:

const client = new AWSAppSyncClient({
  url: process.env.REACT_APP_AWS_APPSYNC_GRAPHQLENDPOINT as string,
  region: process.env.REACT_APP_AWS_APPSYNC_REGION as string,
  auth: {
    type: AUTH_TYPE.OPENID_CONNECT,
    jwtToken: () => getUser().token,
  },
});

And then doing:

<ApolloProvider client={client as any}>
0reactions
undefobjcommented, Oct 14, 2019

Hello everyone - I want to reply and assure you that we have not abandoned support of this project. Per my earlier comment, this is a complex process and to be completely transparent there are things in the Apollo library that are out of our control and there have also been breaking changes in Apollo versions which we’re trying to account for, which is also why we pinned the version. We’ve been spending many hours trying to account for this but it’s not simple to solve. After putting more thought into this we’ve got some initial solutions that I hope will unblock many of you. What we’ve done is packaged two of the “Links” which are part of the SDK - the Auth and Subscription Links - and published them to NPM. This will allow you to include them in the newer Apollo versions if you wish to use the newer features. This does not include the “Offline Link” for offline support which is more complex to solve and we’re looking into for the future.

Installation of the links:

npm install aws-appsync-auth-link aws-appsync-subscription-link

Usage: https://github.com/awslabs/aws-mobile-appsync-sdk-js#using-authorization-and-subscription-links-with-apollo-client-no-offline-support

With is I would then give the following recommendations for choosing your client strategy:

  1. If you do not have offline use cases, you can either use the Auth & Subscription Links above with the latest Apollo client or alternatively use the Amplify GraphQL client instead of Apollo:https://aws-amplify.github.io/docs/js/api#amplify-graphql-client
  2. If you do have offline use cases please use the current version as-is with the older Apollo version. We’re still working on a future strategy for the Offline Link.

Please let us know if you have any trouble using these links or if there is a scenario which we haven’t accounted for here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hooks - Apollo GraphQL Docs
Deprecated. If true , causes a query refetch if the query result is detected as partial. Setting this option is unnecessary in Apollo...
Read more >
Apollo Client Error: Could not find "client" in the context or ...
I had luck with downgrading @apollo/client from v3.5.x to v3.4.17 , and my tests (which is where I got this error) started passing...
Read more >
Angular & Apollo Client: Getting Started with GraphQL in ...
Writing queries & mutations using the Apollo client library; Generating TypeScript types from the server-side schema by graphql-code-generator ...
Read more >
Integrate TypeScript with GraphQL using TypeGraphQL
Bootstrapping our TypeScript GraphQL application; Installing dependencies; Setting up our Apollo server; TypeGraphQL database schema fields ...
Read more >
The React + Apollo Tutorial for 2020 (Real-World Examples)
Plus it makes working with React and GraphQL a lot easier by giving us a lot ... with npm: npm i @apollo/react-hooks apollo-client...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found