Skip to content

Commit c1abd18

Browse files
author
Roy Sutton
committed
Fix sample
Enact-DCO-1.0-Signed-off-by: Roy Sutton [email protected]
1 parent e2f670d commit c1abd18

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

pattern-graphql/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Use Apollo with Enact and Github GraphqQL API
1+
## Use Apollo with Enact and GitHub GraphqQL API
22

33
A sample application that demonstrates how to use GraphqQL with Enact components. It uses [Apollo Client](https://github.com/apollographql/apollo-client), (GraphqQL client.)
44

@@ -19,27 +19,27 @@ Run `npm install` then `npm run serve` to have the app running on [http://localh
1919
- `ui/resolution/scale`
2020

2121
## Setup and use
22-
1. Get a personal access token for the GitHub API from https://github.com/settings/tokens/new.
23-
- Select repo for scopes.
24-
2. Replace the dummy token in [src/config.json](src/config.json) with your token.
25-
3. Install node_modules
22+
1. Get a personal access token for the [GitHub API](https://github.com/settings/tokens/new).
23+
- Assign a name to the token and select the "read:org" scope.
24+
2. Replace the dummy token in [src/config.json](src/config.json) with the token generated above.
25+
3. Install npm modules.
2626

2727
```bash
2828
npm install
2929
```
30-
4. Serve
30+
4. Serve.
3131

3232
```bash
3333
npm run serve
3434
```
3535

36-
5. Open http://localhost:8080/.
37-
6. Search for a github id, selecting which information you wish to retrieve.
36+
5. Open [localhost](http://localhost:8080/).
37+
6. Search for a GitHub id, selecting which information you wish to retrieve.
3838

3939

4040
### How Apollo is used.
4141

42-
In **App.js**, a new ApolloClient is created with github uri and request setup:
42+
In **App.js**, a new `ApolloClient` is created with GitHub URI and request setup:
4343

4444
[src/App/App.js]
4545
```javascript
@@ -67,7 +67,7 @@ import { ApolloProvider } from "react-apollo";
6767
</ApolloProvider>
6868
```
6969

70-
Finally, a graphql query (`GET_USER`) is created using `gql` and is passed as the `query` prop to the `Query` component:
70+
Finally, a GraphQL query (`GET_USER`) is created using `gql` and is passed as the `query` prop to the `Query` component:
7171

7272
[src/views/Detail.js](src/views/Detail.js)
7373
```javascript

pattern-graphql/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "",
2+
"name": "pattern-graphql",
33
"version": "1.0.0",
44
"description": "An Enact Moonstone GraphQL application.",
55
"author": "Hailey HanGyeol Ryu",
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
import {Cell} from '@enact/ui/Layout';
22
import Divider from '@enact/moonstone/Divider';
3-
import kind from '@enact/core/kind';
43
import Item from '@enact/moonstone/Item';
54
import PropTypes from 'prop-types';
6-
import React from 'react';
5+
import React, {Component} from 'react';
76
import {scale} from '@enact/ui/resolution';
87
import VirtualList from '@enact/moonstone/VirtualList';
98

10-
// eslint-disable-next-line enact/display-name, enact/prop-types
11-
const renderItem = ({list}) => ({index, ...rest}) => {
12-
return (
9+
class List extends Component {
10+
static propTypes = {
11+
list: PropTypes.arrayOf(PropTypes.object).isRequired,
12+
userId: PropTypes.string
13+
}
14+
15+
renderItem = ({index, ...rest}) => (
1316
<Item
1417
{...rest}
1518
index={index}
1619
>
17-
{list[index].name}
20+
{this.props.list[index].name}
1821
</Item>
1922
);
20-
};
2123

22-
const List = kind({
23-
name: 'Detail',
24-
25-
propTypes: {
26-
list: PropTypes.arrayOf(PropTypes.object).isRequired,
27-
userId: PropTypes.string
28-
},
24+
render = () => {
25+
const list = this.props.list;
2926

30-
render: ({list}) => {
3127
return [
3228
<Cell key="header" shrink><Divider>Repositories</Divider></Cell>,
3329
<Cell
3430
component={VirtualList} size={list.length <= 4 ? (60 * list.length) : null}
3531
key="list"
3632
dataSize={list.length}
3733
focusableScrollbar={null}
38-
itemRenderer={renderItem}
34+
itemRenderer={this.renderItem}
3935
itemSize={scale(60)}
4036
spacing={0}
4137
/>];
4238
}
43-
});
39+
}
4440

4541
export default List;

pattern-graphql/src/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"token":""
2+
"token":"19813c93ca87e38f38cb0c05e6df04ccdb3de577"
33
}

0 commit comments

Comments
 (0)