# graphql-got

> Convenience wrapper for got to interact with GraphQL

Latest version **0.1.2** (published 2018-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install graphql-got
pnpm add graphql-got
yarn add graphql-got
bun add graphql-got
```

## 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.1.2 |
| Published | 2018-03-14 |
| First published | 2017-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 3 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 103 |
| Author | Kevin Mårtensson |
| Maintainers | kevva |
| Keywords | api, apollo, get, got, graphql, gql, http, https, post, query, relay, request, uri, url, util, utility |

## Links

- npm: https://www.npmjs.com/package/graphql-got
- Repository: https://github.com/kevva/graphql-got
- Homepage: https://github.com/kevva/graphql-got#readme
- Issues: https://github.com/kevva/graphql-got/issues
- npm.io page: https://npm.io/package/graphql-got

## Dependencies (3)

- [got](https://npm.io/package/got.md) ^7.1.0
- [prepend-http](https://npm.io/package/prepend-http.md) ^2.0.0
- [aggregate-error](https://npm.io/package/aggregate-error.md) ^1.0.0

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2018-03-14
- 0.1.1 — 2017-09-24
- 0.1.0 — 2017-09-12

## README

# graphql-got [![Build Status](https://travis-ci.org/kevva/graphql-got.svg?branch=master)](https://travis-ci.org/kevva/graphql-got)

> Convenience wrapper for `got` to interact with [GraphQL](http://graphql.org/)

A lightweight alternative to [`apollo-client`](https://github.com/apollographql/apollo-client) and [`relay`](https://github.com/facebook/relay).


## Install

```
$ npm install graphql-got
```


## Usage

```js
const graphqlGot = require('graphql-got');

const query = `{
	unicorn(name: "Foo Bar") {
		id
		name
	}
}`;

graphqlGot('api.graphql.unicorn', {query}).then(response => {
	console.log(response.body);
	/*
	{
		unicorn: {
			id: 0,
			name: 'Foo Bar'
		}
	}
	*/
});
```


## API

Same as [`got`](https://github.com/sindresorhus/got), but with some additional options below. URLs without protocol will be prepended with `https://`.

### query

*Required*<br>
Type: `string`

The `query` to send to [GraphQL](http://graphql.org/).

### variables

Type: `Object`

Variables to be used in your `query`. Read more [here](http://graphql.org/learn/queries/#variables).

### operationName

Type: `string`

If your `query` contains multiple operations, this option is required to decide which operation to run.

### token

Type: `string`

If defined, an `Authorization` header with `bearer ${TOKEN}` will be sent.


## License

MIT © [Kevin Mårtensson](https://github.com/kevva)

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