Crates.io | graphql-minify |
lib.rs | graphql-minify |
version | 0.1.0 |
source | src |
created_at | 2023-08-11 16:57:17.750842 |
updated_at | 2023-08-11 16:57:17.750842 |
description | Minify GraphQL queries |
homepage | |
repository | https://github.com/dan-lee/graphql-minify-rs |
max_upload_size | |
id | 942131 |
size | 29,498 |
This is a re-implementation of stripIgnoredCharacters
from the GraphQL.js reference implementation in Rust. It uses Logos for tokenization.
All relevant tests are ported from the reference implementation and run against the Rust implementation.
Beware: It does not test for validity of the GraphQL document, its sole purpose is to minify the document as much as possible.
Strips characters that are not significant to the validity or execution of a GraphQL document:
- UnicodeBOM
- WhiteSpace
- LineTerminator
- Comment
- Comma
- BlockString indentation
Note: It is required to have a delimiter character between neighboring non-punctuator tokens and this function always uses single space as delimiter.
It is guaranteed that both input and output documents if parsed would result in the exact same AST except for nodes location.
use graphql_minify::minify;
fn main() {
let minified = minify("query { user { id name } }");
assert_eq!(minified.unwrap(), "query{user{id name}}");
}