greed
Version:
graphql client
135 lines (117 loc) • 2.79 kB
Markdown
# Greed
> A tiny unopinionated 1kb extendable GraphQL client
[]()
[]()
[](http://npm.im/greed)
[](http://npm-stat.com/charts.html?package=greed&from=2015-08-01)
[](https://www.paypal.me/donatetomyoss)
[](http://opensource.org/licenses/MIT)
This library is meant to implement a minimal framework agnostic GraphQL client.
It allows you to query and create mutations on the client. Greed can be easily
extended by other libraries to provide more functionality.
## Install
```bash
npm install --save greed
```
## Shape
```js
Greed:: a -> function
Greed({
url: String,
token: String,
plugins: {
pre: [Function],
post: [Function]
}
});
```
#### In Practice
It should now look like this:
```js
import Greed from 'greed';
var gql = Greed({
url: 'https://localhost:3000/',
token: 'someCrazySuperSecretToken',
plugins: {
pre: [
],
post: [
]
}
});
gql(`{
person(personID: 2){
name
species{
name
}
}
}`);
```
## License
MIT
<!--
## Usage
```js
import React, { Component } from 'react';
import greed from 'greed';
var gql = greed('http://localhost:52394', ''); // second param is for authroken
class App extends Component {
constructor (props) {
super(props);
this.state = {
cp30: ''
};
}
async componentDidMount() {
var data = await gql(`{
person(personID: 2){
name
species{
name
}
}
}`);
this.setState(() => ({cp30: data.data.person.name}));
}
render() {
return (
<div className="App">
<p>{this.state.cp30}</p>
</div>
);
}
}
```
## Usage with Query Variables
```js
import React, { Component } from 'react';
import greed from 'greed';
var gql = greed('http://localhost:52394', ''); // second param is for authtoken
class App extends Component {
constructor (props) {
super(props);
this.state = {
cp30: ''
};
}
async componentDidMount() {
var data = await gql(`query getPerson($personID: ID!){
person(personID: $personID){
name
species{
name
}
}
}`, {personID: 2});
this.setState(() => ({cp30: data.data.person.name}));
}
render() {
return (
<div className="App">
<p>{this.state.cp30}</p>
</div>
);
}
}
```-->