Created
May 16, 2018 12:40
-
-
Save chyavanphadke/d69ea098b0646ecd5252109ebfad507f to your computer and use it in GitHub Desktop.
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
import React, { Component } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
import { createApolloFetch } from 'apollo-fetch'; | |
const uri = 'https://graphql-explorer.githubapp.com/graphql'; | |
const apolloFetch = createApolloFetch({ uri }); | |
class App extends Component { | |
componentWillMount(){ | |
apolloFetch({query: `{ | |
search(query: "12mitul", type: USER, first: 1) { | |
edges { | |
node { | |
... on User { | |
pullRequests(first: 100, states: MERGED) { | |
totalCount | |
edges { | |
node { | |
repository { | |
name | |
} | |
changedFiles | |
additions | |
deletions | |
createdAt | |
closedAt | |
mergedAt | |
commits { | |
totalCount | |
} | |
reviews { | |
totalCount | |
} | |
comments { | |
totalCount | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}`}) //all apolloFetch arguments are optional | |
.then(result => { | |
const { data, errors, extensions } = result; | |
//GraphQL errors and extensions are optional | |
console.log(data, errors, extensions ) | |
}) | |
.catch(error => { | |
//respond to a network error | |
console.log(error) | |
}); | |
} | |
render() { | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
<img src={logo} className="App-logo" alt="logo" /> | |
<h1 className="App-title">Welcome to React</h1> | |
</header> | |
<p className="App-intro"> | |
To get started, edit <code>src/App.js</code> and save to reload. | |
</p> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment