A bring your own types GraphQL client library for Rust
See the code[!IMPORTANT]
This repository has been migrated to Codeberg.
Cynic is a GraphQL library for Rust. It's not the first but it takes a different approach from the existing libraries.
Existing libraries take a query first approach to GQL - you write a query using GraphQL and libraries use that to generate Rust structs for you using macros. This is really easy and great for getting going quickly. However, if you want to use structs that aren't quite what the macros output you're out of luck. Some more complex use cases like sharing structs among queries are also commonly not supported.
Cynic takes a different approach - it uses Rust structs to define queries and
generates GraphQL from them. This gives you freedom to control the structs
you'll be working with while still enjoying type safe queries, checked against
the GraphQL schema. When its built in derives don't do exactly what you
want it provides lower level APIs to hook in and fetch the data you want in the
format you want to work with it.
Of course writing out all the structs to represent a large GraphQL query can be
quite challenging, and GraphQL has excellent tooling for building queries
usually. Cynic provides querygen to help with this - you write a
GraphQL query using the existing GQL tooling and it'll generate some cynic
structs to make that query. You can use this as a starting point for your
projects - either adding on to the rust structs directly, or re-using
querygen as appropriate.
Cynic is currently a work in progress, but the following features are supported:
cynic-cli or cynic-introspectiongraphql-ws-client.@skip, @include and any custom directives that don't
require client support)Cynic is documented in a few places:
If you want help with cynic you can join the #cynic chat room on IRC using any of these options:
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
481 followers · starred Apr 2025
338 followers · starred Feb 2024
292 followers · starred Jan 2022
594 followers · starred Jan 2023
A bring your own types GraphQL client library for Rust
See the code[!IMPORTANT]
This repository has been migrated to Codeberg.
Cynic is a GraphQL library for Rust. It's not the first but it takes a different approach from the existing libraries.
Existing libraries take a query first approach to GQL - you write a query using GraphQL and libraries use that to generate Rust structs for you using macros. This is really easy and great for getting going quickly. However, if you want to use structs that aren't quite what the macros output you're out of luck. Some more complex use cases like sharing structs among queries are also commonly not supported.
Cynic takes a different approach - it uses Rust structs to define queries and
generates GraphQL from them. This gives you freedom to control the structs
you'll be working with while still enjoying type safe queries, checked against
the GraphQL schema. When its built in derives don't do exactly what you
want it provides lower level APIs to hook in and fetch the data you want in the
format you want to work with it.
Of course writing out all the structs to represent a large GraphQL query can be
quite challenging, and GraphQL has excellent tooling for building queries
usually. Cynic provides querygen to help with this - you write a
GraphQL query using the existing GQL tooling and it'll generate some cynic
structs to make that query. You can use this as a starting point for your
projects - either adding on to the rust structs directly, or re-using
querygen as appropriate.
Cynic is currently a work in progress, but the following features are supported:
cynic-cli or cynic-introspectiongraphql-ws-client.@skip, @include and any custom directives that don't
require client support)Cynic is documented in a few places:
If you want help with cynic you can join the #cynic chat room on IRC using any of these options:
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
481 followers · starred Apr 2025
338 followers · starred Feb 2024
292 followers · starred Jan 2022
594 followers · starred Jan 2023