diff --git a/front/src/App.tsx b/front/src/App.tsx index 226ee63..ec6d752 100644 --- a/front/src/App.tsx +++ b/front/src/App.tsx @@ -1,26 +1,39 @@ import React from 'react'; import logo from './logo.svg'; import './App.css'; +import {gql} from 'apollo-boost'; +import {Query} from 'react-apollo'; + +const GET_USERS = gql` + query { + user { + name + } + } +`; const App: React.FC = () => { - return ( -
-
- logo -

- Edit src/App.tsx and save to reload. -

- - Learn React - -
-
- ); + return ( +
+
+ logo +

+ Edit src/App.tsx and save to reload. +

+ + {({loading, error, data}: any) => { + if (loading) return
Loading...
; + if (error) return
Error :(
; + return ( +

+ {data.user.name} +

+ ) + }} +
+
+
+ ); } export default App; diff --git a/front/src/index.tsx b/front/src/index.tsx index 87d1be5..5f3d76f 100644 --- a/front/src/index.tsx +++ b/front/src/index.tsx @@ -3,8 +3,19 @@ import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import * as serviceWorker from './serviceWorker'; +import ApolloClient from 'apollo-boost'; +import {ApolloProvider} from 'react-apollo'; -ReactDOM.render(, document.getElementById('root')); +// Pass your GraphQL endpoint to uri +const client = new ApolloClient({uri: '/graphql'}); + +const ApolloApp = (AppComponent: React.FC) => ( + + + +); + +ReactDOM.render(ApolloApp(App), document.getElementById('root')); // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls.