Expand description
§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 cynics
generator and use the scalars defined in sui_gql_schema.
§Custom queries
Users building their own queries should first:
- add
sui_gql_schemaas a build dependency - register its schema in a
build.rsfile; - import the
schemamodule 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-typetypesmutations: enables themutationssubmodulequeries: enables thequeriessubmodule with pre-made queriesreqwest: enables thereqwestsubmodule with an implementation ofGraphQlClientscalars: re-exports thescalarsmodule 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/graphqlto build queries against the testnet schemahttps://sui-mainnet.mystenlabs.com/graphqlfor 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
Re-exports§
pub use cynic;
Modules§
Macros§
- extract
Deprecated - Helper for extracting data from GraphQL responses.
- missing_
data - Helper to generate
Error::MissingData.
Structs§
- Graph
QlErrors - Error for
GraphQlResponseExt::try_into_data. - Paged
Response - Pages resulting from GraphQL queries.
Enums§
Traits§
- Graph
QlClient - A generic GraphQL client. Agnostic to the backend used.
- Graph
QlResponse Ext - Adds
try_into_data. - Paged
- Interface for paged queries to allow automatic pagination.
- RawClient
- Client that takes a Cynic operation and return the GraphQL response as JSON.
Type Aliases§
- Pages
Data Result - The initial page data and subsequent ones’, if any.