# graphin

> Isomorphic GraphQl client

Latest version **0.0.14** (published 2016-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install graphin
pnpm add graphin
yarn add graphin
bun add graphin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.14 |
| Published | 2016-11-16 |
| First published | 2016-07-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | frux |
| Maintainers | frux |
| Keywords | graphql, isomorphic, client |

## Links

- npm: https://www.npmjs.com/package/graphin
- Repository: https://github.com/frux/graphin
- Homepage: https://github.com/frux/graphin#readme
- Issues: https://github.com/frux/graphin/issues
- npm.io page: https://npm.io/package/graphin

## Dependencies (1)

- [fetch-ponyfill](https://npm.io/package/fetch-ponyfill.md) ^3.0.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.0.14 (latest) — 2016-11-16
- 0.0.13 — 2016-11-16
- 0.0.12 — 2016-09-07
- 0.0.11 — 2016-09-07
- 0.0.10 — 2016-09-05
- 0.0.9 — 2016-08-26
- 0.0.8 — 2016-08-26
- 0.0.7 — 2016-08-25
- 0.0.6 — 2016-08-24
- 0.0.5 — 2016-08-24
- 0.0.4 — 2016-08-24
- 0.0.3 — 2016-08-10
- 0.0.2 — 2016-07-27
- 0.0.1 — 2016-07-27

## README

# Graphin [![Build Status](https://travis-ci.org/frux/graphin.svg?branch=master)](https://travis-ci.org/frux/graphin) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
> Isomorphic JavaScript GraphQL client

```js
import Graphin from 'graphin';

const graphin = new Graphin('https://my.graphql.endpoint.com');

// Simple GraphQL query
graphin.query(`{
	userList {
		login
		name
		email
	}
}`)
	.then(list => {
		console.log(data.userList);
	});


// List of users cached for a minute
graphin.query(`{
	photoList {
		id
		url
		description
		width
		height
	}
}`, {cache: 60000})
	.then(data => {
		console.log(data.photoList);
	});

// Simple GraphQL mutation
graphin.query(`mutation {
	updatePhoto(id: 100500, description: "Photo of a real Unicorn!") {
		id
	}
}`);
```

## API

### new Graphin(endpoint, options, fetcher) ⇒ ``Graphin``

| Param | Type | Description |
| --- | --- | --- |
| endpoint | ``string`` | GraphQL endpoint URL |
| options | ``object|undefined`` | Graphin general options. Affect all requests. Default {} |
| options.cache | ``number`` | Cache TTL in ms |
| options.fetch | ``object`` | Fetch options |
| options.verbose | ``boolean`` | Verbose mode. Default false |
| fetcher | ``function|undefined`` | Fetch function (url, options) => Promise. Default fetch |

-----------------

### graphin.query(url, options) ⇒ ``Promise``
Makes GraphQL Query

| Param | Type | Description |
| --- | --- | --- |
| url | ``string`` | GraphQL Query |
| requestOptions | ``object|undefined`` | Request options. Affect only this request. Merge with general options. Default {} |
| requestOptions.cache | ``number`` | Cache TTL in ms |
| requestOptions.fetch | ``object`` | Fetch options |
| requestOptions.verbose | ``boolean`` | Verbose mode. Default false |

-----------------

### graphin.getQueryURL(query) ⇒ ``string``
Converts GraphQL query to URL

| Param | Type | Description |
| --- | --- | --- |
| query | ``string`` | GraphQL Query |

---
_Source: https://npm.io/package/graphin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
