Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Uncaught TypeError: Cannot set property 'middleware' of undefined" while following instructions for React #808

Closed
bobwhitelock opened this issue Oct 18, 2016 · 4 comments

Comments

@bobwhitelock
Copy link

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!

@pfulop
Copy link
Contributor

pfulop commented Oct 19, 2016

It should benew ApolloClient

@bobwhitelock
Copy link
Author

Doh! Yep that works, thanks!

@stubailo
Copy link
Contributor

Someone could send a pr to throw an error when the constructor is called without new!

@julian-rare
Copy link

why not make it return the new class?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants