@0no-co/graphql.web

中文文档
1.3.4发布于 2026/08/22MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2427.2万

A spec-compliant client-side GraphQL implementation

原始使用文档
文档目录3 节
  1. @0no-co/graphql.web
  2. Overview
  3. API

@0no-co/graphql.web

The spec-compliant minimum of client-side GraphQL.

CI Status Bundlesize Discord

@0no-co/graphql.web is a utility library, aiming to provide the minimum of functions that typical GraphQL clients need and would usually import from graphql, e.g. a GraphQL query parser, printer, and visitor.

While its goal isn’t to be an exact match to the GraphQL.js API it aims to remain API- and type-compatible where possible and necessary. However, its goal is to provide the smallest implementation for common GraphQL utilities that are still either spec-compliant or compatible with GraphQL.js’ implementation.

Note: If you’re instead looking for a drop-in replacement for the graphql package that you can just alias into your web apps, read more about the graphql-web-lite project, which uses this library to shim the graphql package.

@urql/core depends on this package to power its GraphQL query parsing and printing. If you’re using @urql/core@^4 you’re already using this library! ✨

Overview

@0no-co/graphql.web aims to provide a minimal set of exports to implement client-side GraphQL utilities, mostly including parsing, printing, and visiting the GraphQL AST, and the GraphQLError class.

Currently, graphql.web compresses to under 4kB and doesn’t regress on GraphQL.js’ performance when parsing, printing, or visiting the AST.

For all primary APIs we aim to hit 100% test coverage and match the output, types, and API compatibility of GraphQL.js, including — as far as possible — TypeScript type compatibility of the AST types with the currently stable version of GraphQL.js.

API

Currently, only a select few exports are provided — namely, the ones listed here are used in @urql/core, and we expect them to be common in all client-side GraphQL applications.

ExportDescriptionLinks
parseA tiny (but compliant) GraphQL query language parser.Source
printA (compliant) GraphQL query language printer.Source
visitA recursive reimplementation of GraphQL.js’ visitor.Source
KindThe GraphQL.js’ Kind enum, containing supported ASTNode kinds.Source
GraphQLErrorGraphQLError stripped of source/location debugging.Source
valueFromASTUntypedCoerces AST values into JS values.Source

The stated goals of any reimplementation are:

  1. Not to implement any execution or type system parts of the GraphQL specification.
  2. To adhere to GraphQL.js’ types and APIs as much as possible.
  3. Not to implement or expose any rarely used APIs or properties of the GraphQL.js library.
  4. To provide a minimal and maintainable subset of GraphQL.js utilities.

Therefore, while we can foresee implementing APIs that are entirely separate and unrelated to the GraphQL.js library in the future, for now the stated goals are designed to allow this library to be used by GraphQL clients, like @urql/core.

版本与发布记录

@0no-co/graphql.web 共发布 56 个版本,首次发布于 2023/03/20;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.3.4latest2026/08/222 个月前
1.3.32026/07/273 个月前
1.3.22026/06/134 个月前
1.3.12026/06/134 个月前
1.3.02026/06/134 个月前
1.2.02025/07/301.3 年前

其他发布通道:canary → 1.2.0-canary-85c8743265b341d285a4ea3a3cdf12611a13846c。

关于 @0no-co/graphql.web 的常见问题

@0no-co/graphql.web 是什么?

A spec-compliant client-side GraphQL implementation

如何安装 @0no-co/graphql.web?

在项目目录运行 npm install @0no-co/graphql.web,或使用 pnpm add / yarn add / bun add。

@0no-co/graphql.web 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@0no-co/graphql.web 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@0no-co/graphql.web 可以商用吗?

@0no-co/graphql.web 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@0no-co/graphql.web 的下载量有多少?

根据 npm 官方下载统计,@0no-co/graphql.web 在 2026/10/04 – 2026/11/02 这 30 天内被下载 24,272,330 次,日均约 809,078 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@0no-co/graphql.web 还在维护吗?

最新版本 1.3.4 发布于 2026/08/22(2 个月前);至今共发布 56 个版本,其中过去 12 个月发布了 5 个;首次发布于 2023/03/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。