Apollo-client: Docs are wrong / outdated

Created on 25 Jul 2018  路  3Comments  路  Source: apollographql/apollo-client

Sorry I don't have time to read (and try to understand) 40 lines of an ISSUE TEMPLATE

I followed this link

Link: https://www.apollographql.com/docs/react/essentials/get-started.html

I used this code

Code (ts):

import ApolloClient from "apollo-boost";

const client = new ApolloClient({
  uri: "https://w5xlvm3vzz.lp.gql.zone/graphql"
});

All I get is this error:

Error (ts):

TS2345: Argument of type '{ uri: string; }' is not assignable to parameter of type 'ApolloClientOptions<{}>'.
  Object literal may only specify known properties, and 'uri' does not exist in type 'ApolloClientOptions<{}>'.

Please provide examples that actually work. Anything else is just a waste of time.

Most helpful comment

You didn't follow the example exactly. The code sample you're showing here is correct, and will work. The error you're seeing will only show up if you're attempting to reference ApolloClient using a named export. So you probably actually tried this:

import { ApolloClient } from "apollo-boost";

const client = new ApolloClient({
  uri: "https://w5xlvm3vzz.lp.gql.zone/graphql"
});

All 3 comments

You didn't follow the example exactly. The code sample you're showing here is correct, and will work. The error you're seeing will only show up if you're attempting to reference ApolloClient using a named export. So you probably actually tried this:

import { ApolloClient } from "apollo-boost";

const client = new ApolloClient({
  uri: "https://w5xlvm3vzz.lp.gql.zone/graphql"
});

You didn't follow the example exactly. The code sample you're showing here is correct, and will work. The error you're seeing will only show up if you're attempting to reference ApolloClient using a named export. So you probably actually tried this:

import { ApolloClient } from "apollo-boost";

const client = new ApolloClient({
  uri: "https://w5xlvm3vzz.lp.gql.zone/graphql"
});

Could you explain a bit what is the difference between the two? Type hover shows the exact same thing.

@lou00011 the correct way is without referencing the named export鈥攊.e.

import ApolloClient from 'apollo-boost';

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

(ApolloClient, not { ApolloClient })

Was this page helpful?
0 / 5 - 0 ratings