default docs example for 2.0 is not working
See original GitHub issueI copy pasted this code:
import { ApolloClient, HttpLink } from 'apollo-client-preset';
const client = new ApolloClient({
link: new HttpLink({
uri: 'https://graphql.example.com',
}),
});
and this is not working: Error: In order to initialize Apollo Client, you must specify link & cache properties on the config object. This is part of the required upgrade when migrating from Apollo Client 1.0 to Apollo Client 2.0. For more information, please visit: https://apollographql.com/docs/react/setup to help you get started.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
PDF16: Setting the default language using the /Lang entry in ...
Example 2 : Specifying the default document language in a PDF document using Microsoft Word 2007. This example is shown with Microsoft Word....
Read more >SWITCH - Google Docs Editors Help
Tests an expression against a list of cases and returns the corresponding value of the first matching case, with an optional default value...
Read more >OpenAPI Specification - Version 2.0 - Swagger
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be ......
Read more >OAuth 2.0 for Client-side Web Applications | Authorization
This document explains how to implement OAuth 2.0 authorization to access Google APIs from a JavaScript web application. OAuth 2.0 allows ...
Read more >Configuring CircleCI
This document is a reference for the CircleCI 2.x configuration keys that are ... Default: ~/project (where project is a literal string, not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@HamidReazaNikoonia It appears you’re importing the ApolloClient as a named export, but you should be importing it directly. This means just removing the curly brackets ( { } ) around your ApolloClient import. More information on named vs default imports here: https://stackoverflow.com/questions/36795819/when-should-i-use-curly-braces-for-es6-import/36796281
edit: Also seems like you’re using the uri config property for ApolloClient while using the apollo-client package instead of the apollo-boost package. The uri property only works with apollo-boost because has it has default packages in the background that handles everything for you. But, with apollo-client you’re going to have to do that heavy lifting yourself. If all you need is a simple app, you can switch over to apollo-boost, but if you’re looking for features like uploading, you’re better off sticking with apollo-client for manipulating your link. To which other packages you need to setup the client properly you can checkout their docs: https://www.npmjs.com/package/apollo-client
Hope that that helps you out. 😃
I’d like to try creating a PR if no one is on it yet 😃