-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
In order to initialize Apollo Client, you must specify link & cache properties on the config #3639
Comments
Switch: import { ApolloClient } from 'apollo-boost'; to import ApolloClient from 'apollo-boost'; If you do that you'll then be using the Sorry for the confusion! We know this can be a problem, and are planning on changing this around in the future. Thanks! |
You also can import like this: // es6 import
import { default as ApolloClient } from 'apollo-boost';
// es5 or Node.js
const Boost = require('apollo-boost');
const ApolloClient = Boost.DefaultClient; |
@hwillson if you know this can be a problem, why close the issue with the docs still being wrong? |
@curry684 I'm not aware of the docs being wrong anywhere? Can you provide a link? |
For es5 / Node.js the following worked for me:
|
If I'm using
and define my client like:
then I cant use the ApolloProvider with this client:
my Versions:
|
This should be reopen because the error points to the wrong doc, https://www.apollographql.com/docs/react/basics/setup.html. That page redirects to a page that no longer says anything about a I was trying to import only apollo-client (I don't need the other features because I'm writing a minimal example to repro a bug):
|
I just ran into this too with using |
I just stumple upon this, can't create a simple graphql client with one custom header. That's a little bit frustrating. Not sure what to do... I'm using
|
Ran into this issue while following the tutorial, it says to use |
The tutorial is still incorrect, as well. See |
I've run into so many problems with that tutorial. It makes me reconsider whether to use this library at all. |
I keep running into broken code, things that don't make sense, etc. I'm considering submitting a few PRs to make the tuts read better. It is pretty disheartening when a tutorial is so confoundingly difficult to follow. |
I've wasted a day and couldn't get past the client initialization. The link in the error message is wrong, docs are confusing, examples are incomplete with parts missing (because they were considered to be obvious?!). If anybody can recommend another library for GraphQL in React Native, I'm switching boats. |
What makes it even worse is when every tutorial does the same thing in a different way, apollo-that apollo-this |
This should keep folks from continuing to encounter issue #3639.
* Fix error message about ApolloClient({ link, cache }) options. This should keep folks from continuing to encounter issue #3639. * Fix Jest snapshots that depended on the old error message.
this need to be |
If anyone is looking to do what the error says (add link & cache): import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { createHttpLink } from 'apollo-link-http';
const client = new ApolloClient({
link: createHttpLink({ uri: 'http://api.githunt.com/graphql' }),
cache: new InMemoryCache()
}); This example comes from here: I got this error because I was following the example on the "Integrating with React Native" page, which is definitely wrong: |
What about
I've switched to the default import, but trying to use
fails with
Also, any chance to hire someone to look at this tutorial with fresh eyes and clean it up? It's rather embarrassing how many people have had problems with it. |
|
@hwillson I would seriously suggest making this clearer in your docs. Just wasted hours going in a circle with an unclear error that was due to this. |
@maxtheman Apollo client v3 will be changing this behavior, and is expected to release soon. You can try out the beta with the |
That's great news, thank you!
…On Wed, Feb 5, 2020, 8:12 AM Dylan Wulf ***@***.***> wrote:
@maxtheman <https://github.com/maxtheman> Apollo client v3 will be
changing this behavior, and is expected to release soon. You can try out
the beta with the @apollo/client npm package
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3639?email_source=notifications&email_token=AAQSOUL7F6U2BIUWS4OF57TRBLQQDA5CNFSM4FHZGBIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK4AAAI#issuecomment-582483969>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQSOUOEQSOZGZFM3AFB3STRBLQQDANCNFSM4FHZGBIA>
.
|
Do you know if the v3 fixes this error? |
Its 2020 and this combination works for me in React-Native. I feel like a hacker who achieved to hack this beautiful documentation. Application entry point index.js
package.json
component file inside application
|
Solved this issue by the following:
|
Looks like apollo-utilities is doing invariant checking that forces us to use TS instead of JS. There is such thing as "too much validation" and it looks like apollo is doing just that. IT seems to be breaking code during routine node updates and causing incompatibilities with rollup. Also it's 2021 and this error is still linking to the wrong place. |
Just wow. I wanted to do the silliest GraphQL query as a Node.js JavaScript test and simply could not get ApolloClient instantiated. This is straight-up awful. |
I solved this issue by realizing that I was supposed to use BEFORE (NOT WORKING)
NOW (WORKING!!)
Hope this helps someone. |
This is really strange and demotivating using Apollo from the very beginning.
Here is your docs:
I pass the only thing and your package throws
you must specify link & cache properties on the config object
.How can it be?
Intended outcome:
Working client, working app, no erros thrown
Actual outcome:
How to reproduce the issue:
Versions
System:
OS: macOS High Sierra 10.13.4
Binaries:
Node: 8.11.3 - /usr/local/bin/node
npm: 5.6.0 - /usr/local/bin/npm
Browsers:
Chrome: 67.0.3396.99
Safari: 11.1
npmPackages:
apollo-boost: ^0.1.4 => 0.1.5
apollo-cache-inmemory: ^1.1.0 => 1.2.0
apollo-client: ^2.0.3 => 2.3.0
apollo-link: ^1.0.3 => 1.2.2
apollo-link-http: ^1.2.0 => 1.5.4
react-apollo: ^2.1.1 => 2.1.3
The text was updated successfully, but these errors were encountered: