graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

ApolloLink import error when using Apollo Client V3.

Open roydigerhund opened this issue 3 years ago • 4 comments

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • [ ] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • [ ] 2. A failing test has been provided
  • [ ] 3. A local solution has been provided
  • [ ] 4. A pull request is pending review

Describe the bug

I upgraded to Apollo V3 and also updated all @graphql-tools/* packages to the latest version. When trying to use linkToExecutor I'm getting the following error:

./node_modules/@graphql-tools/links/index.mjs
Attempted import error: 'ApolloLink' is not exported from '@apollo/client/link/core'.

I manually changed the import in the package to use '@apollo/client' but it didn't solve the problem.

Does anyone successfully use @graphql-tools/links with @apollo/client^3.5.10?

Environment:

  • OS: macOS 12.2.1 (21D62)
  • @graphql-tools/links: ^8.2.9
  • NodeJS: v14.17.6
  • @apollo/client: ^3.5.10

roydigerhund avatar Apr 12 '22 13:04 roydigerhund

I think it is lack of ESM support on Apollo Client side. Please try to use CJS instead. If still doesn't work, please create a reproduction on CodeSandbox or StackBlitz. Thanks!

ardatan avatar Apr 12 '22 15:04 ardatan

I'm not quite sure about this. Everywhere else I also use ESM syntax for apollo client imports and it works just fine. But I will try it out with CJS imports in the @graphql-tools/links package.

roydigerhund avatar Apr 13 '22 22:04 roydigerhund

@roydigerhund I've updated your initial comment with the Issue workflow progress, do you think you could help us tackle the first phase of progress? Thanks!

Urigo avatar Apr 22 '22 13:04 Urigo

Which template should I fork here?

Make sure to fork this template and run yarn generate in the terminal.

roydigerhund avatar Apr 25 '22 09:04 roydigerhund

This is fixed in v8.3.0 with https://github.com/ardatan/graphql-tools/commit/d76a299cf9ccc3e8b3bc6f36bcb1c32bb61d39f1

yusufkandemir avatar Feb 14 '23 15:02 yusufkandemir