-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
79 lines (69 loc) · 1.64 KB
/
App.tsx
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { useState } from 'react'
import logo from './logo.svg'
import './App.css'
import { useQuery } from 'urql';
import { Article, QueryArticleArgs } from './gql/graphql';
const getArticlesQuery = `
query {
allArticles {
id
}
}
`;
const getArticleQuery = `
query ($id: String!) {
Article (id: $id) {
id
}
}
`;
function App() {
const [count, setCount] = useState(0)
const [result, reexecuteQuery] = useQuery<Article, QueryArticleArgs>({
query: getArticleQuery,
variables: { id: 'another' },
});
const { data, fetching, error } = result;
if (fetching) return <p>Loading...</p>;
if (error) {
console.log(error);
return <p>Oh no... {error.message}</p>;
}
console.log(data);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>Hello Vite + React!</p>
<p>
<button type="button" onClick={() => setCount((count) => count + 1)}>
count is: {count}
</button>
</p>
<p>
Edit <code>App.tsx</code> and save to test HMR updates.
</p>
<p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
{' | '}
<a
className="App-link"
href="https://vitejs.dev/guide/features.html"
target="_blank"
rel="noopener noreferrer"
>
Vite Docs
</a>
</p>
</header>
</div>
)
}
export default App