# Greed
> A tiny unopinionated 1kb extendable GraphQL client

[![Travis](https://img.shields.io/travis/kennetpostigo/greed.svg?style=flat-square)]()
[![Codecov branch](https://img.shields.io/codecov/c/github/kennetpostigo/greed/master.svg?style=flat-square)]()
[![version](https://img.shields.io/npm/v/greed.svg?style=flat-square)](http://npm.im/greed)
[![downloads](https://img.shields.io/npm/dm/greed.svg?style=flat-square)](http://npm-stat.com/charts.html?package=greed&from=2015-08-01)
[![Donate](https://img.shields.io/badge/$-support-green.svg?style=flat-square)](https://www.paypal.me/donatetomyoss)
[![MIT License](https://img.shields.io/npm/l/greed.svg?style=flat-square)](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>
    );
  }
}
```-->
