Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/starptech/graphql-parser-bench
GraphQL parser comparison in different languages
https://github.com/starptech/graphql-parser-bench
Last synced: 21 days ago
JSON representation
GraphQL parser comparison in different languages
- Host: GitHub
- URL: https://github.com/starptech/graphql-parser-bench
- Owner: StarpTech
- License: mit
- Created: 2021-08-14T16:40:37.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-17T08:35:35.000Z (about 3 years ago)
- Last Synced: 2024-10-03T23:42:16.677Z (about 1 month ago)
- Language: Go
- Size: 5.35 MB
- Stars: 23
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graphql-parser-bench
Parsing a schema or document can be a critical part of the application, especially if you have to care about latency. This is the case for proxies or caches where high load is expected. This benchmark should outline good candidates. We use the libraries as documented in tests or documentation. We don't tune a specific parser. We assume that a new query arrives the parser at any time.
## Benchmark
This test requires Rust, Go and Node.js (>=14)
## Intermediate result
### Parsing a schema
Parse the [gitlab schema](./schema.graphql). The schema has a size of around `671KB`.
```sh
./bench.sh ./../schema.graphql schema
```- ✅ graphql-go-tools: 5.7179ms
- ✅ graphql-parser: 7.4608ms
- ✅ gqlparser: 7.7642ms
- ✅ async-graphql-parser: 12.7027ms
- ✅ graphqljs (warmed): 11.1135ms
- ✅ graphqljs (cold): 39.505ms
- ❌ go-graphql: [Error](https://github.com/graphql-go/graphql/issues/611)**🏆 Winner**: In terms of speed `graphql-go-tools` wins!
Compared to different aspect like accessibility and maintainability `async-graphql-parser` is the overall winner. It uses a PEG grammar as input.
### Parsing a query
Parse the [kitchen-sink document](./kitchen-sink.graphql). The document has a size of around `1KB` but with a wide usage of the specification.
```sh
./bench.sh ./../kitchen-sink.graphql query
```
- ✅ graphql-parser: 20.9µs
- ✅ gqlparser: 38.8µs
- ✅ graphql-go-tools: 42.6µs
- ✅ graphqljs (warmed): 0.2104ms
- ✅ graphqljs (cold): 1.4962ms
- ❌ async-graphql-parser: [Error](https://github.com/async-graphql/async-graphql/issues/602)
- ❌ go-graphql: [Error](https://github.com/graphql-go/graphql/issues/612)**🏆 Winner**: In terms of speed `graphql-parser` wins! Alarming that some popular parser can not even parse the query.
## Contribute
Feel free to improve or add another parser to the list. PR's are welcome!