Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for @apollo/client #578

Closed
asadowns opened this issue Jul 28, 2020 · 3 comments
Closed

Add support for @apollo/client #578

asadowns opened this issue Jul 28, 2020 · 3 comments
Labels
Apollo feature-request Have an idea, share it with us!

Comments

@asadowns
Copy link

asadowns commented Jul 28, 2020

Do you want to request a feature or report a bug?
feature and bug
What is the current behavior?
aws-appsync is not currently fully compatible with @apollo/client@3 as the existing apollo-client, apollo-link, etc. are no longer being supported and the recommendation is to migrate away from them.

There seem to be two main blockers here:

  1. aws-appsync has a dependency on apollo-client@2.6 this requires importing both apollo-client and @apollo/client if the new version is desired to be used. The error shown if not importing apollo-client is:
ERROR in ./node_modules/aws-appsync-subscription-link/lib/subscription-handshake-link.js
Module not found: Error: Can't resolve 'apollo-client' in '/my-project-path/node_modules/aws-appsync-subscription-link/lib'
 @ ./node_modules/aws-appsync-subscription-link/lib/subscription-handshake-link.js 81:22-46
 @ ./node_modules/aws-appsync-subscription-link/lib/index.js
 @ ./node_modules/aws-appsync/lib/client.js
 @ ./node_modules/aws-appsync/lib/index.js
 @ ./src/components/config.ts
 @ ./src/components/App.tsx
 @ ./src/index.tsx
 @ multi react-hot-loader/patch ./src/index.tsx
  1. The type of ApolloLink used by createAppSyncLink is no longer consistent with the ApolloLink type provided by @apollo/client. This requires a cast to any.
Type 'ApolloLink' is missing the following properties from type 'ApolloLink': onError, setOnErrorts(2739)
ApolloClient.d.ts(22, 5): The expected type comes from property 'link' which is declared here on type 'ApolloClientOptions<NormalizedCacheObject>'

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Using @apollo/client@3.0.0.

Typing issue comes at:

  const awsLink = createAppSyncLink({ // If this is cast to any that's the current workaround
    url: aws_appsync_graphqlEndpoint,
    region: aws_appsync_region,
    auth: {
      type: AUTH_TYPE.AWS_IAM,
      // eslint-disable-next-line @typescript-eslint/promise-function-async
      credentials: () => Auth.currentCredentials(),
    },
    // eslint-disable-next-line @typescript-eslint/promise-function-async
    complexObjectsCredentials: () => Auth.currentCredentials(),
  });

  const apolloClient = new ApolloClient({
    link: awsLink.concat(httpLink), // This is where the type is invalid
    cache: new InMemoryCache(),
  });

What is the expected behavior?
aws-appsync should work with @apollo/client^3 without additional dependencies or workarounds.

** Relates to**
#448

@sammartinez sammartinez added feature-request Have an idea, share it with us! Apollo labels Jul 29, 2020
@BenoitDel
Copy link

also related to:

@sammartinez
Copy link
Contributor

#561 we are looking to test this and validate this resolves this feature

@manueliglesias
Copy link
Contributor

Hi,

This is addressed in #561 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apollo feature-request Have an idea, share it with us!
Projects
None yet
Development

No branches or pull requests

4 participants