I've been trying to connect to my local GraphQL server using Apollo. Below is my attempt using react-apollo2.0. But I have also tried with react-apollo1.4 with createNetworkInterface, but I am getting the same error.
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
import { AppRegistry } from 'react-native';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloClient } from 'apollo-client';
import { ApolloProvider } from 'react-apollo';
const client = new ApolloClient({
link: new HttpLink({ uri: 'http://localhost:8000/graphql' }),
cache: new InMemoryCache()
});
function FooList({ data: { loading, posts } }) {
if (loading) {
return <Text>Loading</Text>;
} else {
return (
<List>
<ListItem>
<Left>
<Text>John Doe5</Text>
<Text note>(buyer)</Text>
</Left>
<Right>
<Text note>21 min ago</Text>
</Right>
</ListItem>
</List>
);
}
}
export default graphql(gql`
query allLeads {
id
name
}
`)(FooList);
const App = () => (
<ApolloProvider client={client}>
<FooList/>
</ApolloProvider>
);
export default App;
Error I'm getting:
My dependencies.
"dependencies": {
"@expo/vector-icons": "^6.2.0",
"apollo-client-preset": "^1.0.4",
"expo": "^22.0.2",
"graphql": "^0.11.7",
"graphql-tag": "^2.6.0",
"native-base": "^2.3.3",
"react": "16.0.0-beta.5",
"react-apollo": "^2.0.4",
"react-link": "^1.0.3",
"react-native": "^0.49.5",
"react-navigation": "^1.0.0-beta.21"
}
According to the docs this is how you are supposed to set it up. My server isn't being hit and I can access the graph browser at http://localhost:8000/graphql just fine.
What am I missing here?

192.168.1.4. Docs say to uselocalhostas well. - dan-klassonfunction FooList({ data: { error, loading, posts } }) { if (error) { return <Text>{error.message}</Text>; }- Dyo