This repository has been archived by the owner on Aug 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
19 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 |
---|---|---|
@@ -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` | ||
This comment has been minimized.
Sorry, something went wrong. |
||
query { | ||
user { | ||
name | ||
} | ||
} | ||
`; | ||
|
||
const App: React.FC = () => { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo"/> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to reload. | ||
</p> | ||
<Query query={GET_USERS}> | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{({loading, error, data}: any) => { | ||
if (loading) return <div>Loading...</div>; | ||
if (error) return <div>Error :(</div>; | ||
return ( | ||
<p> | ||
{data.user.name} | ||
This comment has been minimized.
Sorry, something went wrong. |
||
</p> | ||
) | ||
}} | ||
</Query> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
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
GraphQLのクエリ