refactor(graphql-client): standardize query_types structure, naming, and extract common module#1016
Conversation
- Extracted common scalars, shared fragments, pagination, and conversions out of query_types/mod.rs into query_types/common.rs. - Standardized all query_types files to consistently include section headers (Queries, Query Args, Types, Conversions). - Renamed all QueryVariables structs (e.g., BalanceArgs -> BalanceQueryArgs) to match Cynic type conventions and updated all matching cynic macro arguments. - Added 18 #[deprecated] type aliases to mod.rs to preserve backward compatibility for downstream consumers of the iota-sdk-graphql-client. - Resolved name collision in normalized_move by renaming MovePackageQuery fragment to MovePackage and creating a local alias. - Updated all import paths across 11 api/*.rs files. No behavioral or logic changes introduced.
This commit addresses several failing checks across the CI pipeline: - Updated deprecated `TransactionsFilter` to `TransactionBlockFilter` and `MovePackageQuery` to `MovePackage` in `iota-sdk-ffi` and examples, clearing strict clippy warnings. - Fixed a broken intra-doc link for `TransactionBlockEffects` in `transaction.rs`, ensuring `cargo doc` builds successfully. - Replaced defunct `generator.cynic-rs.dev` URLs in READMEs with `cynic-cli` documentation links to satisfy the `lychee` link checker workflow. All workflows (`tests.yml`, `lints.yml`, `check_features.yml`, `links_checker.yml`) now pass locally.
We can do this, in fact, with a major version bump. |
Cool, let's remove them. |
- remove deprecated aliases for major version bump
…ent-restructure' into feature/graphql-client-restructure
| @@ -1083,7 +1083,7 @@ impl From<MovePackageQuery> for iota_sdk::graphql_client::query_types::MovePacka | |||
|
|
|||
| #[derive(uniffi::Record)] | |||
| pub struct MoveModuleQuery { | |||
There was a problem hiding this comment.
Why is MovePackage renamed but not this?
There was a problem hiding this comment.
It was conflicted with the MoveModule inside normalized_move/module.rs.
Do you want the MoveModuleNode instead?
There was a problem hiding this comment.
Not necessarily, but the whole point of this issue was to find a way to make these types consistent. I do not think that this PR is currently doing that.
Problem Statement
The
iota-sdk-graphql-clientcrate (specifically thequery_typesmodule) had outgrown its original structure:query_types/mod.rswas heavily bloated (~200 lines), mixing exports, scalar definitions, shared structs, and implementations.QueryVariablestypes were inconsistently named (BalanceArgsvsPackagesQueryArgs).MovePackageQueryandTransactionsFilterwere misleadingly named (the former is a GraphQL fragment, the latter represents a singular filter, not plural).execute_tx.rsfile existed unnecessarily, isolating transaction execution types away from the coretransaction.rsdomain.Solution
This PR executes a pure structural and naming refactor across the
query_types/andapi/modules. There are no logic or runtime business-behavior changes.Specifically, this PR:
query_types/common.rs: Moved all scalars (Base64,BigInt,DateTime, etc.), shared fragments (GQLAddress,MoveObject, etc.), and conversions out ofmod.rs.mod.rsis now strictly a barrel file containing onlymod,pub use, and backward-compatibility aliases.QueryVariablestypes to follow a consistent{Entity}QueryArgspattern (e.g.,BalanceArgs→BalanceQueryArgs,EpochArgs→EpochQueryArgs).query_types/*.rsfiles (Queries → Query Args → Types → Conversions).MovePackageQuerytoMovePackageinpackages.rs.TransactionsFiltertoTransactionBlockFilterintransaction.rs.execute_tx: Moved the contents ofexecute_tx.rsintotransaction.rsand deleted the standalone file, centralizing transaction types.iota-sdk-ffi(bindings) and theiota-sdk/examplesworkspace members so they compile successfully against the newly renamed graphql types.upstream/developregardingTransactionBlockFilterparameter renaming.Backward Compatibility
Since this library is public, we cannot simply break downstream consumers who are using the old type names. To preserve backward compatibility, deprecated type aliases have been added to
query_types/mod.rs.warning: use of deprecated type alias 'BalanceArgs': renamed to BalanceQueryArgs).Testing
cargo test -p iota-sdk-graphql-clientpasses cleanly.NETWORK=testnet cargo test --all-features -p iota-sdk-graphql-clientpasses cleanly.viewCallmutations are currently unsupported on the IOTA testnet infrastructure.test_transaction_data_effectsandtest_transactions_data_effects) that were panicking due to relying on hard-coded devnet digests that had gone stale. They now reliably fetch live digests.cargo check -p iota-sdk-ffisuccessfully compiles against the type aliases.cargo clippy --all-targets --all-featuresthrows zero warnings.Related Issues
Resolves #512