-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathApp.js
63 lines (54 loc) · 1.65 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
56
57
58
59
60
61
62
63
import React from 'react'
import { View } from 'react-native'
import Feed from './src/components/Feed'
// Apollo
import { Rehydrated } from 'aws-appsync-react'
import { ApolloProvider } from 'react-apollo'
// AppSync
import AWSAppSyncClient from "aws-appsync"
// Amplify
import Auth from '@aws-amplify/auth'
import Amplify from '@aws-amplify/core'
import { withAuthenticator } from 'aws-amplify-react-native'
import awsconfig from './src/aws-exports'
Amplify.configure(awsconfig)
// Create a client
const GRAPHQL_API_REGION = awsconfig.aws_appsync_region
const GRAPHQL_API_ENDPOINT_URL = awsconfig.aws_appsync_graphqlEndpoint
const S3_BUCKET_REGION = awsconfig.aws_user_files_s3_bucket_region
const S3_BUCKET_NAME = awsconfig.aws_user_files_s3_bucket
const AUTH_TYPE = awsconfig.aws_appsync_authenticationType
const client = new AWSAppSyncClient({
url: GRAPHQL_API_ENDPOINT_URL,
region: GRAPHQL_API_REGION,
auth: {
type: AUTH_TYPE,
jwtToken: async () => (
await Auth.currentSession()).getAccessToken().getJwtToken(),
},
complexObjectsCredentials: () => Auth.currentCredentials(),
disableOffline: true
})
class App extends React.Component {
render() {
return (
<View style={{ flex: 1, backgroundColor: '#f7edf0' }}>
<Feed
options={{
bucket: S3_BUCKET_NAME,
region: S3_BUCKET_REGION
}}
/>
</View>
)
}
}
// Wrap the App with Amplify HOC. Set to true if you want to render sing out button
const AppWithAuth = withAuthenticator(App, false)
export default () => (
<ApolloProvider client={client}>
<Rehydrated>
<AppWithAuth />
</Rehydrated>
</ApolloProvider>
)