# ugql

> GraphQL.js over HTTP with uWebSockets.js

Latest version **1.1.7** (published 2019-05-19) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.7 |
| Published | 2019-05-19 |
| First published | 2019-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 8.x |
| Dependencies | 2 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Annihil |
| Maintainers | annihil |
| Keywords | ugql, gql, graphql, graphql-js, uws, uWebSockets, uWebSockets.js, uWebSockets-js |

## Links

- npm: https://www.npmjs.com/package/ugql
- Repository: https://github.com/Annihil/ugql
- Issues: https://github.com/Annihil/ugql/issues
- npm.io page: https://npm.io/package/ugql

## Dependencies (2)

- [graphql](https://npm.io/package/graphql.md) ^14.3.0
- [uWebSockets.js](https://npm.io/package/uWebSockets.js.md) github:uNetworking/uWebSockets.js#binaries

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.1.7 (latest) — 2019-05-19
- 1.1.6 — 2019-05-19
- 1.1.5 — 2019-05-19
- 1.1.4 — 2019-05-17
- 1.1.3 — 2019-05-11
- 1.1.2 — 2019-05-11
- 1.1.1 — 2019-05-10
- 1.1.0 — 2019-05-10
- 1.0.1 — 2019-05-07
- 1.0.0 — 2019-05-07

## README

# µGQL
[![npm](https://img.shields.io/npm/v/ugql.svg?style=flat-square)](https://www.npmjs.com/package/ugql)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![package dependencies](https://img.shields.io/david/Annihil/ugql.svg?style=flat-square)](https://david-dm.org/Annihil/ugql)
![](https://img.shields.io/badge/benchmark-150x%20express--graphql-blueviolet.svg?style=flat-square)  
Leveraging [GraphQL-js](https://github.com/graphql/graphql-js) with [µWebSockets.js](https://github.com/uNetworking/uWebSockets.js)

## Installation

`npm i ugql` or `yarn add ugql`

## Usage

Create an `app.mjs` file with the following content:

```js
import uWS from 'uWebSockets.js';
import gql from 'graphql';
import ugql from 'ugql';

const { buildSchema } = gql;
const app = uWS.App();
const ugraphql = ugql(app, async (res, req) => ({})/* middleware */, true /* cors */);

const schema = buildSchema(`
  type Query {
    hello: String
  }
`);

const root = { 
  hello: () => 'Hello world'
};

ugraphql(schema, root);

app.listen(9001, token => token ? console.log('µGQL running on port 9001') : console.log('µGQL failed to run: port already in use'));
```

Then run
```sh
node --experimental-modules app.mjs
```

Quick test, in a developer console
```js
fetch('http://localhost:9001/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ query: "{ hello }" })
})
  .then(r => r.json())
  .then(console.log);
```

You should see
```js
Object { hello: "Hello world!" }
```

# Supported request's types
- GET with query parameter
- POST with content-type
    - application/json
    - application/x-www-form-urlencoded
    - application/graphql

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