Skip to content
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

Error: To initialize Apollo Client, specify link & cache properties #8

Open
steinitz opened this issue Dec 11, 2018 · 6 comments
Open

Comments

@steinitz
Copy link

Hi,

Liking the course. Thank you.

Is anyone else getting

In order to initialize Apollo Client, you must specify link & cache properties on the config object...

when yarn starting the code per the book at page 94?

@rwieruch
Copy link
Member

I asked in the Slack Community if anyone ran into the issue. Did you double check it with this repository's implementation?

When I search for the error, I find this issue: apollographql/apollo-client#3639

Can you share your project?

@steinitz
Copy link
Author

Thanks for your reply.

I worked around the issue using information from the link you mentioned and other related links (i.e. I added the link & cache properties per the error message). After solving subsequent issues I'm stuck on another problem. It's probably not appropriate to mention it here. If and when I resolve it, I'll report back here.

I downloaded your project and ran it, intending to test it with more-recent Apollo libraries. However, now I'm getting Network Error 401 for all Apollo projects. The previous, non-apollo, "vanilla" GraphQL project continues to work. Again, I'll report back if and when I discover anything useful. Or perhaps the Slack Community is a better platform for such exchanges.

These problems are a tremendous opportunity to really learn the frameworks. Thanks for getting me to this point with your fine course.

Thanks again for sharing the course - it's a big help. I can sense your investment of time and head-scratching getting it into shape. Bravo.

@swyxio
Copy link

swyxio commented Dec 15, 2018

ran into this too. :(

Edit:

a lot of the docs have been written with Apollo Client 3.0 in mind, where apollo-boost has been merged into core. however it hasn't yet been done, not even in alpha, so this is the problem when actually trying out whats in the docs. to fix, just import and use from apollo-boost for now.

import ApolloClient from 'apollo-boost';

const client = new ApolloClient({
  uri: 'http://localhost:4000/graphql' // no error
});

@rwieruch
Copy link
Member

Thank you @sw-yx for confirming this and helping out with a fix. Crazy that they are already working on v3. Feels like yesterday that v2 has been launched 🗡

In the book, it says initialize ApolloClient with this URI:

import ApolloClient from 'apollo-boost';

const client = new ApolloClient({
  uri: 'https://api.github.com/graphql',
});

What's different in your fix except for the URI (which wouldn't work with the GitHub API)?

It works for me when I clone this repository from GitHub, npm install and npm start it with my GitHub credentials. So I am a bit clueless why you are running into this issue :(

@swyxio
Copy link

swyxio commented Dec 17, 2018

oh i wasnt cloning the repo. i was following the new tutorial on their site and ran into this error. searched the error and found this issue and one other issue over there. found the fix and copy pasted on both issues

@rwieruch
Copy link
Member

Ah okay! Now it makes sense 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants