Skip to content

refactor(graphql-client): standardize query_types structure, naming, and extract common module#1016

Open
MrSufferer wants to merge 8 commits intoiotaledger:developfrom
MrSufferer:feature/graphql-client-restructure
Open

refactor(graphql-client): standardize query_types structure, naming, and extract common module#1016
MrSufferer wants to merge 8 commits intoiotaledger:developfrom
MrSufferer:feature/graphql-client-restructure

Conversation

@MrSufferer
Copy link

@MrSufferer MrSufferer commented Mar 9, 2026

Problem Statement

The iota-sdk-graphql-client crate (specifically the query_types module) had outgrown its original structure:

  • query_types/mod.rs was heavily bloated (~200 lines), mixing exports, scalar definitions, shared structs, and implementations.
  • QueryVariables types were inconsistently named (BalanceArgs vs PackagesQueryArgs).
  • Individual query files lacked a consistent organizational structure.
  • MovePackageQuery and TransactionsFilter were misleadingly named (the former is a GraphQL fragment, the latter represents a singular filter, not plural).
  • The execute_tx.rs file existed unnecessarily, isolating transaction execution types away from the core transaction.rs domain.

Solution

This PR executes a pure structural and naming refactor across the query_types/ and api/ modules. There are no logic or runtime business-behavior changes.

Specifically, this PR:

  1. Extracts query_types/common.rs: Moved all scalars (Base64, BigInt, DateTime, etc.), shared fragments (GQLAddress, MoveObject, etc.), and conversions out of mod.rs. mod.rs is now strictly a barrel file containing only mod, pub use, and backward-compatibility aliases.
  2. Standardizes Naming: Renamed 18 QueryVariables types to follow a consistent {Entity}QueryArgs pattern (e.g., BalanceArgsBalanceQueryArgs, EpochArgsEpochQueryArgs).
  3. Standardizes File Layout: Applied consistent section headers across all 18 query_types/*.rs files (Queries → Query Args → Types → Conversions).
  4. Renames Misleading Types:
    • Renamed MovePackageQuery to MovePackage in packages.rs.
    • Renamed TransactionsFilter to TransactionBlockFilter in transaction.rs.
  5. Consolidates execute_tx: Moved the contents of execute_tx.rs into transaction.rs and deleted the standalone file, centralizing transaction types.
  6. Cross-Crate Updates: Updated iota-sdk-ffi (bindings) and the iota-sdk/examples workspace members so they compile successfully against the newly renamed graphql types.
  7. Resolves Upstream Conflicts: Resolves integration conflicts with upstream/develop regarding TransactionBlockFilter parameter 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.

  • Downstream users will get a deprecation warning telling them the new struct name (e.g., warning: use of deprecated type alias 'BalanceArgs': renamed to BalanceQueryArgs).

Testing

  • Unit Tests: cargo test -p iota-sdk-graphql-client passes cleanly.
  • Integration Tests: NETWORK=testnet cargo test --all-features -p iota-sdk-graphql-client passes cleanly.
    • Note: 2 view call tests fail expectedly because viewCall mutations are currently unsupported on the IOTA testnet infrastructure.
    • Fixed two fragile tests (test_transaction_data_effects and test_transactions_data_effects) that were panicking due to relying on hard-coded devnet digests that had gone stale. They now reliably fetch live digests.
  • Bindings & FFI: cargo check -p iota-sdk-ffi successfully compiles against the type aliases.
  • Linting: cargo clippy --all-targets --all-features throws zero warnings.

Related Issues

Resolves #512

- 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.
@MrSufferer MrSufferer requested a review from a team as a code owner March 9, 2026 09:44
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.
@DaughterOfMars
Copy link
Contributor

Since this library is public, we cannot simply break downstream consumers who are using the old type names.

We can do this, in fact, with a major version bump.

@MrSufferer
Copy link
Author

MrSufferer commented Mar 10, 2026

Since this library is public, we cannot simply break downstream consumers who are using the old type names.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is MovePackage renamed but not this?

Copy link
Author

@MrSufferer MrSufferer Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was conflicted with the MoveModule inside normalized_move/module.rs.
Do you want the MoveModuleNode instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty] Improve iota-sdk-graphql-client structure and uniformity

2 participants