5 releases
new 0.14.1 | Jan 17, 2025 |
---|---|
0.14.0 | Jan 14, 2025 |
0.13.4 | Jan 14, 2025 |
0.13.3 | Jan 14, 2025 |
0.13.2 | Jan 12, 2025 |
#635 in Magic Beans
182 downloads per month
Used in 3 crates
335KB
9K
SLoC
Sui GraphQL client
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 cynic
s
generator and use the scalars defined in sui_gql_schema
.
Custom queries
Users building their own queries should first:
- add
sui_gql_schema
as a build dependency - register its schema in a
build.rs
file; - import the
schema
module in any module defining new fragments
For 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
.
Features
move-types
: compatibility withaf-move-type
typesmutations
: enables themutations
submodulequeries
: enables thequeries
submodule with pre-made queriesreqwest
: enables thereqwest
submodule with an implementation ofGraphQlClient
scalars
: re-exports thescalars
module ofsui_gql_schema
Handy links:
- Query builder: generator.cynic-rs.dev. When prompted either
- click the "A URL" button and pass in:
https://sui-testnet.mystenlabs.com/graphql
to build queries against the testnet schemahttps://sui-mainnet.mystenlabs.com/graphql
for the mainnet one
- click the "I'll Paste It" button and paste the schema
- click the "A URL" button and pass in:
- Cynic's guide
Dependencies
~10–23MB
~314K SLoC