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

@graphql-tools/links requires react as dependency

Open AGrzes opened this issue 3 years ago • 5 comments
trafficstars

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 Version 8.3.0 requires react as dependency.

To Reproduce Steps to reproduce the behavior: For example import

import { createServerHttpLink } from '@graphql-tools/links'

And try to run without react on path Expected behavior

Graphql tools are possible to run server side without react dependency.

Environment:

  • OS: Any
  • @graphql-tools/8.3.0:
  • NodeJS: Any

Additional context

It looks like https://github.com/ardatan/graphql-tools/commit/d76a299cf9ccc3e8b3bc6f36bcb1c32bb61d39f1 added

import * as apolloImport from '@apollo/client';

That triggers react dependency @apollo/client/core should be used instead

AGrzes avatar Jul 20 '22 13:07 AGrzes

@apollo/client is not a valid esm entry on Node.js as the exports map is missing. Thus, doing a deep import is not possible.

I changed this import within this pr in order to make the package usable on ESM. I already informed the apollo team about this in this comment exactly one month ago. So far there has not been any action and I am worried there won't be happening anything soon.

See these related issues that only got labeled...

  • https://github.com/apollographql/apollo-client/issues/9925
  • https://github.com/apollographql/apollo-client/issues/9890

We can change back this code once @apollo/client has a proper import map.


As an alternative, I propose you to nur use ApolloLinks on Node.js (there is IMHO no specific reason for using it), you can just use the http.request function or [email protected].

n1ru4l avatar Jul 24 '22 08:07 n1ru4l