| Crates.io | sui-gql-client |
| lib.rs | sui-gql-client |
| version | 0.20.3 |
| created_at | 2025-01-12 16:27:00.886455+00 |
| updated_at | 2025-09-18 00:11:46.305107+00 |
| description | Sui GraphQL RPC client by Aftermath using `cynic` |
| homepage | |
| repository | https://github.com/AftermathFinance/aftermath-sdk-rust |
| max_upload_size | |
| id | 1513394 |
| size | 283,736 |
First version of Aftermath's Sui GraphQL client using cynic.
The main item here is the GraphQlClient trait, defining the common
interface for clients interacting with an RPC. See the reqwest feature for a pre-made
implementation.
The queries inclued here (under feature queries) were constructed with the help of cynics
generator and use the scalars defined in sui_gql_schema.
Users building their own queries should first:
sui_gql_schema as a build dependencybuild.rs file;schema module in any module defining new fragmentsFor steps 1 and 2, you can check this crate's [build-dependencies] and build.rs for an
example of how to do so. Read more about schema crates in https://cynic-rs.dev/large-apis.
Then, to create query structs, we recommend using the generator with Sui's GraphQL
schema and to try reusing the scalars defined in scalars
as those automatically convert opaque types to more useful ones like af_sui_types.
move-types: compatibility with af-move-type typesmutations: enables the mutations submodulequeries: enables the queries submodule with pre-made queriesreqwest: enables the reqwest submodule with an implementation of
GraphQlClientscalars: re-exports the scalars module of sui_gql_schemahttps://sui-testnet.mystenlabs.com/graphql to build queries against the testnet schemahttps://sui-mainnet.mystenlabs.com/graphql for the mainnet oneYou need to import the TLS backend feature yourself in order to use HTTPS. Since this crate only provides a client implementation using reqwest, that means enabling one of its TLS features, e.g.,
reqwest = { features = ["native-tls"], ... }reqwest = { features = ["rustls-tls"], ... }Otherwise, you'll get an error like
$ cargo run --example gql-latest-checkpoint
# ...
Error:
0: Client error: Inner(ReqwestError(reqwest::Error { kind: Request, url: "https://sui-testnet.mystenlabs.com/graphql", source: hyper_util::client::legacy::Error(Connect, "invalid URL, scheme is not http") }))
Location:
crates/sui-gql-client/examples/latest_checkpoint.rs:21
This is why the [dev-dependencies] here use reqwest = { features = ["rustls-tls"], ... }, otherwise the crate examples would fail.