A resilient GraphQL document analyzer that extends GraphQL's built-in `parse` to gracefully handle validation errors, top-level comments, and invalid sections. Unlike the standard parser, it never throws on malformed input, instead representing invalid parts as `InvalidOperationDefinition`, `InvalidFragmentDefinition`, and `Ignored` nodes. It also supports interpolation with previous valid revisions to recover approximate ASTs for in-progress edits, a section-aware visitor, and a print function that preserves all original content including comments and invalid parts. The package is currently at version 0.7.0 and ships TypeScript type definitions.
npm install graphql-document-analyzerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to analyze a GraphQL document with a comment and an invalid query, iterate over sections, and print back the original content.
Use `doc.definitions.length > 0` to determine if valid definitions exist.
If you need formatted output, use `graphql`'s `print` on the `definitions` only.
Always pass the return value of `analyze` as the reference.
Upgrade graphql to version 15 or later.
Use `import { analyze } from 'graphql-document-analyzer'`Use `import { interpolate } from 'graphql-document-analyzer'`Update graphql to version 15 or later.