Skip to content

Instantly share code, notes, and snippets.

@chyavanphadke
Created May 16, 2018 12:40
Show Gist options
  • Save chyavanphadke/d69ea098b0646ecd5252109ebfad507f to your computer and use it in GitHub Desktop.
Save chyavanphadke/d69ea098b0646ecd5252109ebfad507f to your computer and use it in GitHub Desktop.
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