peter flanagan
peter flanagan

Reputation: 9830

ApolloClient is not a constructor react-apollo

I am following this tutorial and trying to implement graphQl. There is an issue with the following line:

const client = new ApolloClient();

Strangely I cannot find anything in the react-apollo GitHub page for this. Is there something stupid that I am doing wrong.

import React, { Component } from 'react';
import ChannelsList from './ChannelsList.js';
import './App.css';

import {
  ApolloClient,
  gpl,
  graphql,
  ApolloProvider
} from 'react-apollo';


//issue with this line
const client = new ApolloClient();

const channelsListQuery = `
  query ChannelsListQuery {
    channels {
      id,
      name
    }
  }
`;

const ChannelsListWithData = graphql(channelsListQuery)(ChannelsList);

class App extends Component {
  render() {
    return (
      <ApolloProvider client={client}>
        <ChannelsListWithData />
      </ApolloProvider>
    );
  }
}

export default App;

Upvotes: 2

Views: 1545

Answers (2)

Tomas Varga
Tomas Varga

Reputation: 1440

To provide a straightforward answer - ApolloClient is no longer a part of the react-apollo package, but made it to a package of it's own: apollo-client.

You may also see it being imported from apollo-boost, a convenience which "includes some packages that we [Apollo's authors] think are essential to developing with Apollo Client."

Upvotes: 3

Jessica Salmon
Jessica Salmon

Reputation: 11

having the same issue here and actually following the same article (https://dev-blog.apollodata.com/full-stack-react-graphql-tutorial-582ac8d24e3b) as the OP. The issue is that the article is really old and out of date and I would not recommend using it as a guide (take a look at the comments in the article).

For a start I'd recommend looking at the docs. This link (http://graphql.org/graphql-js/) in particular is a good starting place for getting something up and running.

Upvotes: 1

Related Questions