Skip to content
This repository was archived by the owner on Oct 23, 2018. It is now read-only.

Commit e3b52d1

Browse files
committed
Update dependencies.
Adds pseudocode for handling localhost issues. Adds ESLint. Formats code according to Prettier config.
1 parent 9403b14 commit e3b52d1

File tree

9 files changed

+1322
-768
lines changed

9 files changed

+1322
-768
lines changed

Diff for: minimal/.eslintrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": "airbnb",
4+
"plugins": ["react", "react-native", "jsx-a11y", "import"],
5+
"rules": {
6+
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"]}]
7+
},
8+
{
9+
"env": {
10+
"jest": true
11+
}
12+
}
13+
}

Diff for: minimal/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
.expo/
33
npm-debug.*
4+
.DS_Store

Diff for: minimal/App.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
import React from 'react';
2-
import { ApolloProvider } from 'react-apollo';
3-
import { ApolloClient, HttpLink, InMemoryCache } from 'apollo-client-preset';
4-
import Home from './Home';
1+
import React from 'react'
2+
import { Platform } from 'react-native'
3+
import { ApolloProvider } from 'react-apollo'
4+
import { ApolloClient, HttpLink, InMemoryCache } from 'apollo-client-preset'
5+
import Home from './Home'
56

6-
const httpLink = new HttpLink({ uri: 'http://localhost:4000' });
7+
const SERVER_URL = __DEV__
8+
? Platform.select({
9+
ios: 'http://10.0.1.23:4000',
10+
android: 'http://10.0.2.2:4000',
11+
})
12+
: 'INSERT_PRODUCTION_URL'
713

814
const client = new ApolloClient({
9-
link: httpLink,
10-
cache: new InMemoryCache()
11-
});
15+
link: new HttpLink({ uri: SERVER_URL }),
16+
cache: new InMemoryCache(),
17+
})
1218

1319
export default class App extends React.Component {
1420
render() {
1521
return (
1622
<ApolloProvider client={client}>
1723
<Home />
1824
</ApolloProvider>
19-
);
25+
)
2026
}
2127
}

Diff for: minimal/Home.js

+25-14
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,50 @@
1-
import React from 'react';
2-
import { StyleSheet, Text, View } from 'react-native';
3-
import { graphql } from 'react-apollo';
4-
import gql from 'graphql-tag';
1+
import React from 'react'
2+
import { StyleSheet, Text, View } from 'react-native'
3+
import { graphql } from 'react-apollo'
4+
import gql from 'graphql-tag'
55

66
class Home extends React.Component {
77
render() {
8-
if (this.props.helloQuery.loading)
8+
if (this.props.data.error) {
9+
return (
10+
<View style={styles.container}>
11+
<Text>{JSON.stringify(this.props.data.error)}</Text>
12+
</View>
13+
)
14+
}
15+
16+
if (this.props.data.loading) {
917
return (
1018
<View style={styles.container}>
1119
<Text>Loading...</Text>
1220
</View>
13-
);
21+
)
22+
}
1423

1524
return (
1625
<View style={styles.container}>
17-
<Text>{this.props.helloQuery.hello}</Text>
26+
<Text>{this.props.data.hello}</Text>
1827
</View>
19-
);
28+
)
2029
}
2130
}
2231

2332
const styles = StyleSheet.create({
2433
container: {
2534
alignItems: 'center',
2635
flex: 1,
27-
justifyContent: 'center'
28-
}
29-
});
36+
justifyContent: 'center',
37+
},
38+
})
3039

3140
const HELLO_QUERY = gql`
3241
query HelloQuery {
3342
hello
3443
}
35-
`;
44+
`
3645

3746
export default graphql(HELLO_QUERY, {
38-
name: 'helloQuery'
39-
})(Home);
47+
options: {
48+
fetchPolicy: 'network-only',
49+
},
50+
})(Home)

Diff for: minimal/app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"expo": {
3-
"sdkVersion": "24.0.0"
3+
"sdkVersion": "25.0.0"
44
}
55
}

Diff for: minimal/package.json

+21-9
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
"version": "0.1.0",
44
"private": true,
55
"devDependencies": {
6-
"jest-expo": "24.0.0",
7-
"react-native-scripts": "1.8.1",
8-
"react-test-renderer": "16.0.0"
6+
"eslint": "^4.18.0",
7+
"eslint-config-airbnb": "^16.1.0",
8+
"eslint-config-airbnb-base": "^12.1.0",
9+
"eslint-plugin-import": "^2.8.0",
10+
"eslint-plugin-jsx-a11y": "^6.0.3",
11+
"eslint-plugin-react": "^7.6.1",
12+
"eslint-plugin-react-native": "^3.2.1",
13+
"jest-expo": "25.1.0",
14+
"react-native-scripts": "^1.11.1",
15+
"react-test-renderer": "^16.2.0"
916
},
1017
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
1118
"scripts": {
@@ -19,12 +26,17 @@
1926
"preset": "jest-expo"
2027
},
2128
"dependencies": {
22-
"apollo-client-preset": "1.0.6",
23-
"expo": "24.0.2",
24-
"graphql": "0.12.3",
25-
"graphql-tag": "2.6.1",
26-
"react": "16.0.0",
29+
"apollo-client-preset": "^1.0.8",
30+
"expo": "25.0.0",
31+
"graphql": "^0.13.1",
32+
"graphql-tag": "^2.7.3",
33+
"react": "16.2.0",
2734
"react-apollo": "2.0.4",
28-
"react-native": "https://github.com/expo/react-native/archive/sdk-24.0.0.tar.gz"
35+
"react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz"
36+
},
37+
"prettier": {
38+
"semi": false,
39+
"singleQuote": true,
40+
"trailingComma": "all"
2941
}
3042
}

Diff for: minimal/server/package.json

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
{
22
"name": "minimal-server",
33
"scripts": {
4-
"start": "node index.js",
5-
"deploy": "now --public && now alias && now rm --yes --safe graphql-template-node"
4+
"start": "node index.js"
65
},
76
"dependencies": {
8-
"graphql-yoga": "1.1.4"
9-
},
10-
"devDependencies": {
11-
"now": "9.0.1"
12-
},
13-
"now": {
14-
"alias": "graphql-template-node"
7+
"graphql-yoga": "^1.2.5"
158
}
169
}

0 commit comments

Comments
 (0)