Registry / devops / grafast

grafast

JSON →
library1.0.2jsnpmunverified

An alternative GraphQL execution engine for JavaScript that plans and optimizes queries before execution. Version 1.0.2, actively developed with regular releases on npm. Unlike GraphQL.js's default execute, Gra*fast* analyzes the full request upfront, creates an operation plan (detailing abstract steps), optimizes it (removing duplicates, merging steps), and then executes. This leads to significant performance gains, especially for complex queries. It supports both traditional resolvers and new 'plan resolvers' for deeper integration. Requires Node >=22, GraphQL.js v16+, and @envelop/core v5+. Ships TypeScript types. Backward compatible with most existing GraphQL.js schemas.

npm install grafast
INSTALL
IMPORT
SIG · GRAFAST
G
grafast
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

grafast
import { grafast } from 'grafast'
const grafast = require('grafast')
ESM-only package; CommonJS require will not work.
GrafastExecutionArgs
import { GrafastExecutionArgs } from 'grafast'
import GrafastExecutionArgs from 'grafast'
Named export, not default.
GrafastExecutionResult
import { GrafastExecutionResult } from 'grafast'
import { GrafastExecutionResult } from 'grafast/core'
It's a top-level export, not from a subpath.
default
import grafast from 'grafast'
const grafast = require('grafast').default
There is no default export; use named exports instead.

Shows minimal usage: building a GraphQL.js schema, parsing a query, and executing with grafast as a drop-in replacement for GraphQL.js execute.

import { grafast } from 'grafast'; import { buildSchema, parse } from 'graphql'; const schema = buildSchema(` type Query { hello: String } `); const source = `{ hello }`; const document = parse(source); const result = await grafast({ schema, document, contextValue: {}, variableValues: {}, operationName: undefined, }); console.log(result); // { data: { hello: 'world' } }
Debug
Known issues
gotchaContext must be an object suitable as WeakMap key (e.g., plain object or class instance).
fix
Ensure contextValue is an object (not null, not a primitive).
affects: >=1.0.0
gotchaDefault GraphQL field resolver must not be overridden.
fix
Do not replace the default field resolver; Gra*fast* relies on it.
affects: >=1.0.0
breakingRequires Node.js >= 22.
fix
Upgrade Node.js to version 22 or later.
affects: >=1.0.0
breakingRequires @envelop/core ^5.0.0 as a peer dependency.
fix
Install @envelop/core@^5.0.0 alongside grafast.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/grafast/index.js from ... not supported.
Grafast is ESM-only but attempted to load via require().
fix
Use import statements or dynamic import() instead of require().
TypeError: context must be an object
Passed non-object as contextValue to grafast().
fix
Provide a plain object or class instance as contextValue.
Cannot find module '@envelop/core'
Missing peer dependency @envelop/core.
fix
Run npm install @envelop/core@^5.0.0.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
@envelop/corerequiredPeer dependency required for integration with Envelop plugin system
graphqlrequiredPeer dependency - requires GraphQL.js v16+
Agent activity
6 hits · last 30 days
node
6
Resources
grafast — npm install grafast · libregistry