Created
June 12, 2018 20:32
-
-
Save Jeyloh/ce6394c05795733610039b53d55d4a25 to your computer and use it in GitHub Desktop.
Configuration in index.js
This file contains hidden or 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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import registerServiceWorker from './registerServiceWorker'; | |
import { Rehydrated } from 'aws-appsync-react' | |
import { ApolloProvider } from 'react-apollo' | |
import Client from 'aws-appsync' | |
import Amplify, { Auth } from 'aws-amplify' | |
import { withAuthenticator } from 'aws-amplify-react' | |
import AppSync from './AppSync' | |
import awsExports from './aws-exports'; | |
Amplify.configure(awsExports); | |
const client = new Client ({ | |
url: AppSync.graphqlEndpoint, | |
region: AppSync.region, | |
auth: { | |
type: AppSync.authenticationType, | |
jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken() | |
} | |
}) | |
const AppWithAuth = withAuthenticator(App); | |
const AppWithApollo = () => ( | |
<ApolloProvider client={client}> | |
<Rehydrated> | |
<AppWithAuth /> | |
</Rehydrated> | |
</ApolloProvider> | |
) | |
ReactDOM.render(<AppWithApollo />, document.getElementById('root')); | |
registerServiceWorker(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment