| Crates.io | oak-graphql |
| lib.rs | oak-graphql |
| version | 0.0.1 |
| created_at | 2025-10-21 00:13:40.133185+00 |
| updated_at | 2026-01-23 04:28:29.88924+00 |
| description | GraphQL query language parser with support for modern GraphQL specifications and schema definitions. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1892934 |
| size | 60,712 |
High-performance incremental GraphQL parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
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.
Basic example:
use oak_graphql::{Parser, GraphQLLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
query GetUser($id: ID!) {
user(id: $id) {
name
email
posts {
title
content
}
}
}
"#);
let result = parser.parse(&source);
println!("Parsed GraphQL successfully.");
Ok(())
}
use oak_graphql::{Parser, GraphQLLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
query GetUsers($limit: Int, $offset: Int) {
users(limit: $limit, offset: $offset) {
id
name
email
createdAt
}
totalUsers
}
"#);
let result = parser.parse(&source);
println!("Query parsed successfully.");
use oak_graphql::{Parser, GraphQLLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
mutation CreateUser($input: CreateUserInput!) {
createUser(input: $input) {
id
name
email
createdAt
}
}
"#);
let result = parser.parse(&source);
println!("Mutation parsed successfully.");
use oak_graphql::{Parser, GraphQLLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
type User {
id: ID!
name: String!
email: String!
posts: [Post!]!
createdAt: DateTime!
}
type Post {
id: ID!
title: String!
content: String!
author: User!
createdAt: DateTime!
}
type Query {
user(id: ID!): User
users(limit: Int, offset: Int): [User!]!
post(id: ID!): Post
posts(limit: Int, offset: Int): [Post!]!
}
"#);
let result = parser.parse(&source);
println!("Schema parsed successfully.");
use oak_graphql::{Parser, GraphQLLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("query { user { name } }");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_graphql::{Parser, GraphQLLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
// Invalid GraphQL code example
query BrokenQuery {
user {
name
email
// Missing closing brace
// Missing closing brace for query
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak GraphQL integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.