question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

default docs example for 2.0 is not working

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
jordanmauriciocommented, May 28, 2018

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

1reaction
misoguycommented, Nov 3, 2017

I’d like to try creating a PR if no one is on it yet 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found