Oak GraphQL Parser
High-performance incremental GraphQL parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
🎯 Overview
Oak GraphQL is a robust parser for GraphQL, designed to handle complete GraphQL syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for static analysis and code generation.
✨ Features
- Complete GraphQL Syntax: Supports all GraphQL features including modern specifications
- Full AST Generation: Generates comprehensive Abstract Syntax Trees
- Lexer Support: Built-in tokenization with proper span information
- Error Recovery: Graceful handling of syntax errors with detailed diagnostics
🚀 Quick Start
Basic example:
use ;
📋 Parsing Examples
Query Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Mutation Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Schema Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
🔧 Advanced Features
Token-Level Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Error Handling
use ;
let parser = new;
let source = new;
let result = parser.parse;
if let Some = result.result.err else
🏗️ AST Structure
The parser generates a comprehensive AST with the following main structures:
- GraphQLProgram: Root container for GraphQL programs
- Query: GraphQL query definitions
- Mutation: GraphQL mutation definitions
- Subscription: GraphQL subscription definitions
- Fragment: GraphQL fragment definitions
- Type: GraphQL type definitions
- Directive: GraphQL directive definitions
📊 Performance
- Streaming: Parse large GraphQL files without loading entirely into memory
- Incremental: Re-parse only changed sections
- Memory Efficient: Smart AST node allocation
- Fast Recovery: Quick error recovery for better IDE integration
🔗 Integration
Oak GraphQL integrates seamlessly with:
- Static Analysis: Code quality and security analysis
- Code Generation: Generating code from GraphQL AST
- IDE Support: Language server protocol compatibility
- Refactoring: Automated code refactoring
- Documentation: Generating documentation from GraphQL code
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete GraphQL program parsing
- Query, mutation, and subscription analysis
- Schema parsing and validation
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.