-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
apollo-client require react
??
#7318
Comments
It's a peer dependency. |
@yaquawa did you find a way to fix this without adding react as an (unnecessary) dependency? |
@skourismanolis No, it requires react even if you don't use react at all... it really shouldn't force users to use react. |
@baruchvlz I'm using it now. it requires apollo-client. |
Is there a way to remove react from the dependencies if we are not using it? |
@victorgarciaesgi I suppose you could fork the repo and remove the dependency from package.json but that's now a good long-term solution What really must happen is since the |
This takes extra 298 kB if you don't use react. which is nonsense for non-react users. |
@yaquawa I completly agree. I use Vue and I just updated to v3 and I want to switch back. Even for Node users this is nonsense |
I just stumbled across that same problem, but I got the client to work without having to install react. It'd be nice to have that documented somewhere, though. |
@cmd-johnson I followed the docs here and imported everything from import { ApolloClient, InMemoryCache, ApolloLink } from '@apollo/client/core';
import { setContext } from '@apollo/client/link/context';
import apolloLogger from 'apollo-link-logger';
import { onError } from '@apollo/client/link/error';
import { createUploadLink } from 'apollo-upload-client'; Is there something i'm missing? |
Ok I found it. For anyone having this issue the error comes from // node_modules/apollo-link-logger/es/index.js
var _client = require('@apollo/client'); I will open a PR |
@victorgarciaesgi Thanks that helps! |
These changes made it run:
package.json
|
I'm having this issue as well using @apollo/client in my Angular project. Importing from @apollo/client/core fixes the problem but I'm unsure why ... I think Apollo shouldn't rely on react since it's an optional peer dependency |
The problem is that @apollo/client exports from ./react and ./core. It makes sense if the package is react friendly and as bonus works for other frameworks, but if the package intentions are to be framework free, it should only export from ./core and make react users import from @apollo/client/react instead. |
After trying to find how to run a query and mutation using the docs, I found out that everything is based on react, so probably this package is meant to be used only with react, and as bonus it works for other frameworks too. Sadly the docs are lacking on how to use the ApolloClient without using react hooks, also lacking in how to use the package without react at all ( where you get that you need to use @apollo/client/core is in the migration from 2.x, that makes no sense ). So I would suggest to improve the documentation a little bit with a section on how to use this package without react and also on how to use queries, mutations and so on ( doesn't need to be focused on frontend frameworks, just on which method to use and its properties ). Edit: There is a part of documentation on how to use the core apollo/core but it does need improvements, some examples would be helpful, actually good typescript support and not "any" everything and a better explaining about the types "TVariables" what is that? how it works? I will be studying on how to use it better inside my project so I do undertand it more and will make a PR with hopefully better docs, making the types obvious. |
Apollo Client 4 is going to remove React from the default |
This is insane but the problem was caused by the old apollo-client dependency which is 3 years old. The error was coming from ts-invariant code here https://github.com/apollographql/invariant-packages/blob/master/packages/ts-invariant/src/invariant.ts#L64 By this change I updated our app to use new @apollo/client dependency but there is one pretty big concern. This lib has react as a peer dependency (what?!) so to avoid adding react to our vue project I had to import needed functionality from @apollo/client/core instead of just @apollo/client. There is a discussion here apollographql/apollo-client#7318 According to this ^ apollo team are going to remove react from their peer dependecies list when apollo V4 will be launched. See apollographql/apollo-client#8190 That's another point why we should move away from using graphql entirely or at least stop using apollo. Issue: #5371 Change-Id: Ifd484efbcd9e99d8c2e21d0dab93670c9358e25c
I got this error when compiling with WebPack 5.
I'm using vue, does this mean the apollo-client require
react
as a dependency?The text was updated successfully, but these errors were encountered: