forked from Immortalin/onefraction
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set up client with gql, type gen and router
- Loading branch information
1 parent
1814d7c
commit 3928113
Showing
15 changed files
with
1,610 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,7 @@ buck-out/ | |
# Tests | ||
|
||
.jest/ | ||
coverage/ | ||
coverage/ | ||
|
||
# ENV | ||
src/config/development.env.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "example", | ||
"displayName": "example" | ||
"name": "onefraction", | ||
"displayName": "OneFraction" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
overwrite: true | ||
schema: 'http://localhost:4000/graphql' | ||
documents: src/**/*.{graphql,ts,tsx} | ||
generates: | ||
src/generated/graphql.tsx: | ||
plugins: | ||
- 'typescript' | ||
- 'typescript-operations' | ||
- 'typescript-react-apollo' | ||
config: | ||
withHOC: false | ||
withComponent: false | ||
withHooks: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as React from 'react' | ||
import { ApolloProvider } from 'react-apollo' | ||
import { ApolloProvider as ApolloHooksProvider } from 'react-apollo-hooks' | ||
import Router from '../Router' | ||
import { client } from '../../utils/apollo' | ||
|
||
const App = () => { | ||
return ( | ||
<ApolloProvider client={client}> | ||
<ApolloHooksProvider client={client}> | ||
<Router /> | ||
</ApolloHooksProvider> | ||
</ApolloProvider> | ||
) | ||
} | ||
|
||
export default App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './App' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { NativeRouter, Route as NativeRoute, Link as NativeLink } from 'react-router-native' | ||
|
||
export let Router = NativeRouter | ||
export let Route = NativeRoute | ||
export let Link = NativeLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { BrowserRouter, Route as WebRoute, Link as WebLink } from 'react-router-dom' | ||
|
||
export let Router = BrowserRouter | ||
export let Route = WebRoute | ||
export let Link = WebLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as React from 'react' | ||
import { View, Text, StyleSheet } from 'react-native' | ||
import { Router, Route, Link } from './Router' | ||
|
||
const Home = () => <Text>Home</Text> | ||
const About = () => <Text>About</Text> | ||
|
||
export default () => { | ||
return ( | ||
<Router> | ||
<View style={styles.container}> | ||
<View style={styles.nav}> | ||
<Link to="/"> | ||
<Text>Home</Text> | ||
</Link> | ||
<Link to="/about"> | ||
<Text>About</Text> | ||
</Link> | ||
</View> | ||
|
||
<Route exact path="/" component={Home} /> | ||
<Route path="/about" component={About} /> | ||
</View> | ||
</Router> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
alignItems: 'center', | ||
backgroundColor: '#F5FCFF', | ||
flex: 1, | ||
justifyContent: 'center', | ||
}, | ||
nav: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-around', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ApolloClient } from 'apollo-client' | ||
import { ApolloLink } from 'apollo-link' | ||
import { createHttpLink } from 'apollo-link-http' | ||
import { InMemoryCache } from 'apollo-cache-inmemory' | ||
import { AccountsGraphQLClient } from '@accounts/graphql-client' | ||
import { AccountsClientPassword } from '@accounts/client-password' | ||
import { AccountsClient } from '@accounts/client' | ||
import { accountsLink } from '@accounts/apollo-link' | ||
import { GRAPHQL_URL } from './env' | ||
|
||
const httpLink = createHttpLink({ | ||
uri: GRAPHQL_URL, | ||
}) | ||
|
||
const cache = new InMemoryCache() | ||
|
||
// accounts js | ||
export const graphQLApolloClient = new ApolloClient({ | ||
link: ApolloLink.from([httpLink]), | ||
cache, | ||
}) | ||
|
||
export const accountsGraphQL = new AccountsGraphQLClient({ | ||
graphQLClient: graphQLApolloClient, | ||
}) | ||
export const accounts = new AccountsClient({}, accountsGraphQL) | ||
export const accountsPassword = new AccountsClientPassword(accounts) | ||
|
||
// regular apollo client | ||
const authLink = accountsLink(() => accounts) | ||
|
||
export const client = new ApolloClient({ | ||
link: ApolloLink.from([authLink, httpLink]), | ||
cache, | ||
}) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
interface ENV { | ||
NODE_ENV: string | ||
GRAPHQL_URL: string | ||
} | ||
|
||
function getEnvVars(env = '', envVars: any): ENV { | ||
if (env.indexOf('development') !== -1) return envVars.dev | ||
if (env.indexOf('staging') !== -1) return envVars.staging | ||
if (env.indexOf('prod') !== -1) return envVars.prod | ||
return envVars.dev | ||
} | ||
|
||
const dev = require('../config/development.env.json') | ||
const env = getEnvVars(process.env.NODE_ENV, { | ||
dev, | ||
// staging: { | ||
// | ||
// }, | ||
// prod: { | ||
// | ||
// } | ||
}) | ||
|
||
export const NODE_ENV = env.NODE_ENV | ||
export const GRAPHQL_URL = env.GRAPHQL_URL |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.