File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 11import React from 'react'
22import ReactDOM from 'react-dom' ;
33import './scss/main.scss'
4+ import { ApolloProvider } from '@apollo/react-hooks'
5+ import ShowCountries from '../src/components/ShowCountries'
6+ import ApolloClient from 'apollo-boost'
7+
8+ const client = new ApolloClient ( {
9+ uri : 'https://countries-274616.ew.r.appspot.com/'
10+ } )
11+
412const App = ( ) => {
513 return (
6- < div > asd</ div >
14+ < ApolloProvider client = { client } >
15+ < div className = "" >
16+ < ShowCountries />
17+ </ div >
18+ </ ApolloProvider >
719 )
820}
921
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { useQuery } from '@apollo/react-hooks' ;
3+ import { gql } from 'apollo-boost' ;
4+
5+ const GET_COUNTRIES = gql `
6+ query {
7+ Country {
8+ name
9+ area
10+ nativeName
11+ }
12+ }
13+ `
14+
15+
16+ const showCountries = ( ) => {
17+ const { loading, error, data } = useQuery ( GET_COUNTRIES ) ;
18+
19+ return (
20+ < div >
21+ { ! loading &&
22+ data . Country . map ( ( country , i ) => {
23+ return (
24+ < li key = { i } > { country . name } ---- { country . nativeName } --- { country . area } </ li >
25+ )
26+ } )
27+ }
28+ </ div >
29+ )
30+ }
31+
32+ export default showCountries ;
You can’t perform that action at this time.
0 commit comments