ardatan / graphql-tools

:wrench: Utility library for GraphQL to build, stitch and mock GraphQL schemas in the SDL-first approach
https://www.graphql-tools.com
MIT License
5.35k stars 818 forks source link

@graphql-tools/links requires react as dependency #4582

Open AGrzes opened 2 years ago

AGrzes commented 2 years ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow


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:

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

n1ru4l commented 2 years ago

@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...

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 node-fetch@2.x.x.