-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
55 lines (46 loc) · 1.35 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* eslint-disable no-alert */
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import type {Node} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {ApolloClient, InMemoryCache, ApolloProvider} from '@apollo/client';
import {from, HttpLink} from '@apollo/client';
import {onError} from '@apollo/client/link/error';
import Profile from './screens/Profile';
import Story from './screens/Story';
const Stack = createNativeStackNavigator();
const errorLink = onError(({graphqlErrors, networkError}) => {
if (graphqlErrors) {
graphqlErrors.map(({message, location, path}) => {
alert(`Graphql error ${message}`);
});
}
});
const link = from([
errorLink,
new HttpLink({uri: 'http://localhost:6969/graphql'}),
]);
const client = new ApolloClient({
link: link,
cache: new InMemoryCache(),
});
const App: () => Node = () => {
return (
<ApolloProvider client={client}>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen component={Profile} name="Profile" />
<Stack.Screen component={Story} name="Story" />
</Stack.Navigator>
</NavigationContainer>
</ApolloProvider>
);
};
export default App;