Mirror: The spec-compliant minimum of client-side GraphQL.
1<div align="center">
2 <h2>@0no-co/graphql.web</h2>
3 <strong>The spec-compliant minimum of client-side GraphQL.</strong>
4 <br />
5 <br />
6 <a href="https://github.com/0no-co/graphql.web/actions/workflows/release.yml">
7 <img alt="CI Status" src="https://github.com/0no-co/graphql.web/actions/workflows/release.yml/badge.svg?branch=main" />
8 </a>
9 <a href="https://npmjs.com/package/@0no-co/graphql.web">
10 <img alt="Bundlesize" src="https://deno.bundlejs.com/?q=@0no-co/graphql.web&badge" />
11 </a>
12 <a href="https://urql.dev/discord">
13 <img alt="Discord" src="https://img.shields.io/discord/1082378892523864074?color=7389D8&label&logo=discord&logoColor=ffffff" />
14 </a>
15 <br />
16 <br />
17</div>
18
19`@0no-co/graphql.web` is an **experimental** library, aiming to provide an
20absolute minimum of features and exports of `graphql` utilities that typical
21GraphQL web apps or GraphQL clients need.
22
23While its goal isn’t to be an exact match to [the GraphQL.js
24API](https://graphql.org/graphql-js/graphql/) it aims to provide API- and
25type-compatible where possible and necessary. However, its goal is to provide
26the smallest implementation for common GraphQL utilities that are still either
27spec-compliant or compatible with GraphQL.js’ implementation.
28
29> **Note:** While this library can be used as a drop-in replacement for
30> `graphql` in _some cases_, the [`graphql-web-lite`
31> project](https://github.com/0no-co/graphql-web-lite) is maintained to be
32> a full shim/alias for the `graphql` package.
33
34### Overview
35
36`@0no-co/graphql.web` aims to provide a minimal set of exports to implement
37client-side GraphQL utilities, mostly including parsing, printing, and visiting
38the GraphQL AST, and the `GraphQLError` class.
39
40Currently, `graphql.web` compresses to under 4kB and doesn’t regress on
41GraphQL.js’ performance when parsing, printing, or visiting the AST.
42
43For all primary APIs we aim to hit 100% test coverage and match the output,
44types, and API compatibility of GraphQL.js, including — as far as possible
45— TypeScript type compatibility of the AST types with the currently stable
46version of GraphQL.js.
47
48### API
49
50Currently, only a select few exports are provided — namely, the ones listed here
51are used in `@urql/core`, and we expect them to be common in all client-side
52GraphQL applications.
53
54| Export | Description | Links |
55| --- | ----------- | -------- |
56| `parse` | A tiny (but compliant) GraphQL query language parser. | [Source](./src/parser.ts) |
57| `print` | A (compliant) GraphQL query language printer. | [Source](./src/printer.ts) |
58| `visit` | A recursive reimplementation of GraphQL.js’ visitor. | [Source](./src/printer.ts) |
59| `Kind` | The GraphQL.js’ `Kind` enum, containing supported `ASTNode` kinds. | [Source](./src/kind.ts) |
60| `GraphQLError` | `GraphQLError` stripped of source/location debugging. | [Source](./src/kind.ts) |
61| `valueFromASTUntyped` | Coerces AST values into JS values. | [Source](./src/values.ts) |
62
63The stated goals of any reimplementation are:
641. Not to implement any execution or type system parts of the GraphQL
65 specification.
662. To adhere to GraphQL.js’ types and APIs as much as possible.
673. Not to implement or expose any rarely used APIs or properties of the
68 GraphQL.js library.
694. To provide a minimal and maintainable subset of GraphQL.js utilities.
70
71Therefore, while we can foresee implementing APIs that are entirely separate and
72unrelated to the GraphQL.js library in the future, for now the stated goals are
73designed to allow this library to be used by GraphQL clients, like
74[`@urql/core`](https://github.com/urql-graphql/urql).