# genql-runtime

> Genql runtime client

Latest version **1.1.28** (published 2020-09-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install genql-runtime
pnpm add genql-runtime
yarn add genql-runtime
bun add genql-runtime
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.28 |
| Published | 2020-09-29 |
| First published | 2020-05-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 14 |
| Unpacked size | 124.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 978 |
| Author | Tommaso De Rossi, morse |
| Maintainers | xmorse |

## Links

- npm: https://www.npmjs.com/package/genql-runtime
- Repository: https://github.com/remorses/genql
- Homepage: https://genql.now.sh/
- npm.io page: https://npm.io/package/genql-runtime

## Dependencies (14)

- [ws](https://npm.io/package/ws.md) ^6.1.4
- [tslib](https://npm.io/package/tslib.md) ^2.0.0
- [@types/qs](https://npm.io/package/@types/qs.md) ^6.9.0
- [@types/ws](https://npm.io/package/@types/ws.md) ^6.0.1
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.assign](https://npm.io/package/lodash.assign.md) ^4.2.0
- [utility-types](https://npm.io/package/utility-types.md) ^3.10.0
- [@types/lodash.get](https://npm.io/package/@types/lodash.get.md) ^4.4.6
- [lodash.startswith](https://npm.io/package/lodash.startswith.md) ^4.2.1
- [zen-observable-ts](https://npm.io/package/zen-observable-ts.md) ^0.8.21
- [isomorphic-unfetch](https://npm.io/package/isomorphic-unfetch.md) ^3.0.0
- [@types/lodash.assign](https://npm.io/package/@types/lodash.assign.md) ^4.2.6
- [@types/lodash.startswith](https://npm.io/package/@types/lodash.startswith.md) ^4.2.6
- [subscriptions-transport-ws](https://npm.io/package/subscriptions-transport-ws.md) ^0.9.16

## Recent versions

- 1.1.28 (latest) — 2020-09-29
- 2.0.3 (beta) — 2020-09-06
- 1.1.27 — 2020-08-25
- 1.1.26 — 2020-08-25
- 1.1.25 — 2020-08-14
- 1.1.24 — 2020-08-13
- 1.1.23 — 2020-08-13
- 1.1.22 — 2020-07-16
- 1.1.21 — 2020-07-11
- 1.1.20 — 2020-07-11
- 1.1.19 — 2020-07-10
- 1.1.18 — 2020-07-10
- 1.1.17 — 2020-07-10
- 1.1.16 — 2020-07-10
- 1.1.15 — 2020-07-10
- … 74 more at https://npm.io/package/genql-runtime/versions

## README

<div align='center'>
    <br/>
    <br/>
    <img src='https://genql.dev/banner.png' width='380px'>
    <br/>
    <br/>
    <h3>Type safe Graphql query builder</h3>
    <h4>Write Graphql queries with type validation and auto completion</h4>
    <br/>
    <br/>
</div>

> [!IMPORTANT]
> Genql is building a cloud platform to automate SDK generation in multiple languages, docs website with examples, changelog website and more. 
> Fill [this form](https://tally.so/r/mK1GWM) if you are interested!

Read the [quick start guide](https://genql.dev/docs) to generate your client and start writing queries.

You can stay up to date with the latest changes subscribing to the [Genql changelog](https://changelog.genql.dev).

**Features**

-   ✅ Type completion & Type validation
-   🍃 No dependencies (not even graphql)
-   ⚡️ [Can easily fetch all scalar fields in a type](https://genql.dev/docs/usage/fetch-all-fields-on-a-type)
-   🐎 [Works with any client (Apollo, Relay, etc)](https://genql.dev/docs/usage/integrate-with-other-graphql-clients)
-   🥃 [Support for Subscriptions](https://genql.dev/docs/usage/subscriptions)
-   🔋 [Built in batching support](https://genql.dev/docs/usage/batching-queries)
-   ↔️ [Easy migrate existing GraphQL queries to Genql code](https://genql.dev/converter)
-   🚂 Works in browser, Node, Deno, Cloudflare workers, Bun and more

## Example

First generate your client with the `genql` cli.

> You can find other cli options [here](https://genql.dev/docs/cli-reference)

```sh
npm i -D @genql/cli # cli to generate the client code
genql --schema ./schema.graphql --output ./generated
```

Then you can use your client as follow

```js
import { createClient, everything } from './generated'
const client = createClient()

client
    .query({
        countries: {
            // pass arguments to the query
            __args: {
                filter: {
                    currency: {
                        eq: 'EUR',
                    },
                },
            },
            name: true,
            code: true,
            nestedField: {
                // fetch all scalar fields
                __scalar: true,
            },
        },
    })
    .then(console.log)
```

The code above will fetch the graphql query below

```graphql
query {
    countries(filter: { currency: { eq: "EUR" } }) {
        name
        code
        nestedField {
            scalarField1
            scalarField2
        }
    }
}
```

## Why

Genql has a lot of benefits over writing graphql queries by hand:

-   Writing queries is faster thanks to TypeScript auto completion
-   You can safely update your schema and be sure your queries are still valid
-   You can fetch all scalar fields in a type with `__scalar: true`
-   No `graphql` package dependency, no runtime parsing of queries
-   You have to generate the client only after your schema changes, not after every query change

---

## Sponsors

[**Notaku**](https://notaku.so)

[![Notaku](https://notaku.so/github_banner.jpg)](https://notaku.so)

[![Vercel](https://genql.dev/vercel-logo.svg)](https://vercel.com?utm_source=genql)

---

[Licensed under MIT]().

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