graphql-lookahead

JSON →
library 1.4.0 ·javascript
verified Jun 7, 2026

graphql-lookahead is a TypeScript library (v1.4.0) that enables GraphQL resolvers to check whether specific fields are requested in the incoming operation (query/mutation). This allows optimizing database queries by avoiding fetching nested relationships when not needed. It works with any GraphQL server and ORM. The library is actively maintained with regular releases and provides accurate field/type/hierarchy checks through a callback-based API (`until`, `next`, `nextFragment`). Key differentiators: lightweight, no magic AST parsing, typed, and supports fragment spreads. Peer dependency: graphql 16.x. ESM-only, ships TypeScript types.