Hi - while following the instructions here I get Uncaught TypeError: Cannot set property 'middleware' of undefined
when trying to create an ApolloClient
. Here's the relevant code:
import React from 'react';
import ReactDOM from 'react-dom';
import ApolloClient, {createNetworkInterface} from 'apollo-client';
import { ApolloProvider } from 'react-apollo';
import App from './App';
import './index.css';
const client = ApolloClient({
networkInterface: createNetworkInterface('https://api.github.com/graphql')
});
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById('root')
);
I also saw this issue, which suggests I might need to do this instead:
const client = ApolloClient({
networkInterface: createNetworkInterface({uri: 'https://api.github.com/graphql'})
});
This gives exactly the same error however.
Using [email protected]
with [email protected]
. Any idea what I might be doing wrong?
Also here's a repo with the issue, if that helps. Thanks!
It should benew ApolloClient
Doh! Yep that works, thanks!
Someone could send a pr to throw an error when the constructor is called without new!
why not make it return the new class?
Most helpful comment
It should be
new ApolloClient