MCPcopy Index your code
hub / github.com/0no-co/graphql.web

github.com/0no-co/graphql.web @v1.3.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.3.2 ↗ · + Follow
96 symbols 246 edges 36 files 0 documented · 0% 3 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

@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.

Export Description Links
parse A tiny (but compliant) GraphQL query language parser. Source
print A (compliant) GraphQL query language printer. Source
visit A recursive reimplementation of GraphQL.js’ visitor. Source
Kind The GraphQL.js’ Kind enum, containing supported ASTNode kinds. Source
GraphQLError GraphQLError stripped of source/location debugging. Source
valueFromASTUntyped Coerces 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.

Extension points exported contracts — how you extend this code

EnterLeaveVisitor (Interface)
(no doc)
src/visitor.ts
TypeCoordinateNode (Interface)
(no doc)
src/coordinateAst.ts
Extensions (Interface)
(no doc)
src/types.ts
MemberCoordinateNode (Interface)
(no doc)
src/coordinateAst.ts
ArgumentCoordinateNode (Interface)
(no doc)
src/coordinateAst.ts
DirectiveCoordinateNode (Interface)
(no doc)
src/coordinateAst.ts
DirectiveArgumentCoordinateNode (Interface)
(no doc)
src/coordinateAst.ts

Core symbols most depended-on inside this repo

parse
called by 109
src/parser.ts
parseValue
called by 44
src/parser.ts
ignored
called by 36
src/parser.ts
print
called by 23
src/printer.ts
visit
called by 18
src/visitor.ts
parseType
called by 16
src/parser.ts
error
called by 15
src/parser.ts
nameNode
called by 14
src/parser.ts

Shape

Function 82
Interface 7
Method 4
Class 2
Enum 1

Languages

TypeScript100%

Modules by API surface

src/printer.ts29 symbols
src/parser.ts18 symbols
scripts/rollup.config.mjs7 symbols
src/error.ts6 symbols
src/__tests__/visitor.test.ts6 symbols
fixtures/graphql16-new/index.ts6 symbols
src/coordinateAst.ts5 symbols
fixtures/graphql16-old/index.ts4 symbols
src/visitor.ts3 symbols
src/values.ts2 symbols
src/helpers.ts2 symbols
src/__tests__/printer.test.ts2 symbols

For agents

$ claude mcp add graphql.web \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact