Skip to content
Permalink
Browse files

01-Writing your first React GraphQL Client

  • Loading branch information...
rwieruch committed Oct 26, 2018
1 parent 7d66b65 commit ca7b278b8f602c46dfac64a1304d39a8e8e0006b
Showing with 62 additions and 24 deletions.
  1. +9 −0 package-lock.json
  2. +1 −0 package.json
  3. +52 −17 src/App.js
  4. +0 −7 src/logo.svg

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-scripts": "2.0.5"
@@ -1,25 +1,60 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import axios from 'axios';

const TITLE = 'React GraphQL GitHub Client';

const axiosGitHubGraphQL = axios.create({
baseURL: 'https://api.github.com/graphql',
headers: {
Authorization: `bearer ${
process.env.REACT_APP_GITHUB_PERSONAL_ACCESS_TOKEN
}`,
},
});

class App extends Component {
state = {
path: 'the-road-to-learn-react/the-road-to-learn-react',
};

componentDidMount() {
// fetch data
}

onChange = event => {
this.setState({ path: event.target.value });
};

onSubmit = event => {
// fetch data

event.preventDefault();
};

render() {
const { path } = this.state;

return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<div>
<h1>{TITLE}</h1>

<form onSubmit={this.onSubmit}>
<label htmlFor="url">
Show open issues for https://github.com/
</label>
<input
id="url"
type="text"
value={path}
onChange={this.onChange}
style={{ width: '300px' }}
/>
<button type="submit">Search</button>
</form>

<hr />

{/* Here comes the result! */}
</div>
);
}

This file was deleted.

Oops, something went wrong.

0 comments on commit ca7b278

Please sign in to comment.
You can’t perform that action at this time.