Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dan-lee/graphql-minify-rs
Minify any GraphQL document in Rust
https://github.com/dan-lee/graphql-minify-rs
graphql minification rust
Last synced: 10 days ago
JSON representation
Minify any GraphQL document in Rust
- Host: GitHub
- URL: https://github.com/dan-lee/graphql-minify-rs
- Owner: dan-lee
- License: mit
- Created: 2023-08-11T16:27:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-24T16:50:46.000Z (about 1 year ago)
- Last Synced: 2024-10-31T15:52:54.745Z (17 days ago)
- Topics: graphql, minification, rust
- Language: Rust
- Homepage: http://graphql-minify.daniellehr.de
- Size: 49.8 KB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql-minify
This is a re-implementation of [`stripIgnoredCharacters`](https://graphql-js.org/api/function/stripignoredcharacters/) from the [GraphQL.js reference implementation](https://github.com/graphql/graphql-js) in Rust. It uses [Logos](https://github.com/maciejhirsz/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.
[**⚡️ Demo built with WASM**](http://graphql-minify.daniellehr.de)
Details
> 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.## Usage
~~~rust
use graphql_minify::minify;fn main() {
let minified = minify("query { user { id name } }");assert_eq!(minified.unwrap(), "query{user{id name}}");
}
~~~