-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.js
62 lines (56 loc) · 1.22 KB
/
App.js
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
import React, { Component } from 'react';
import { graphql, gql } from 'react-apollo';
import './App.css';
// Data arrives in the `data` prop
// Read more in http://dev.apollodata.com/react/queries.html
class App extends Component {
renderList() {
if (this.props.data.loading) {
return <div>Loading...</div>;
}
return (
<ul>
{this.props.data.Repository.map(repo => (
<li>
<a href={repo.url}>{repo.full_name}</a>
:{' '}
{repo.favorites}
{' '}stars,{' '}
{repo.open_issues}
{' '}issues
</li>
))}
</ul>
);
}
render() {
return (
<div className="App">
<h1>Recently updated repositories:</h1>
{this.renderList()}
</div>
);
}
}
// Declare a query tagged with "gql"
// Write new queries here: http://graphql.communitygraph.org/graphiql/
const query = gql`
{
Repository(orderBy: [updated_desc], first: 20) {
url
created
favorites
updated
full_name
homepage
language
score
open_issues
owner {
name
}
}
}
`;
// Attach the query to the component
export default graphql(query)(App);