Skip to content

[graphql-alt] Update Object return type to Option to support partial error response [1/n]#24595

Merged
tpham-mysten merged 2 commits intomainfrom
tpham-object-partial-error-graphql
Dec 15, 2025
Merged

[graphql-alt] Update Object return type to Option to support partial error response [1/n]#24595
tpham-mysten merged 2 commits intomainfrom
tpham-object-partial-error-graphql

Conversation

@tpham-mysten
Copy link
Copy Markdown
Contributor

Description

Add partial error support for GraphQL resolvers in sui-indexer-alt-graphql by changing return types from Result<Option<T>, E> to Option<Result<T, E>> for IObject interface fields.

Key Changes

Return Type Pattern Change:

  • Changed IObject interface field return types from Result<Option, RpcError> to Option<Result<T, RpcError>>
  • This enables async-graphql's partial error handling: when a field errors, the field becomes null and the error is recorded, but sibling fields still return data

Files Modified:

  • object.rs: Updated IObject interface declarations and Object resolvers (version, digest, objectAt, objectBcs, objectVersionsAfter, objectVersionsBefore, owner, previousTransaction, storageRebate, receivedTransactions)
  • move_object.rs: Updated MoveObject delegation methods with .ok()? pattern
  • move_package.rs: Updated MovePackage resolvers including packageVersionsAfter, packageVersionsBefore
  • coin_metadata.rs: Updated CoinMetadata delegation methods
  • dynamic_field.rs: Updated DynamicField delegation methods

Test plan

How did you test the new or updated feature?

cargo nextest run -p sui-indexer-alt-e2e-tests

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL: Partial error will be properly supported in GraphQL. Invalid fields will have error messages and valid fields will still be displayed normally
  • CLI:
  • Rust SDK:
  • Indexing Framework:

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sui-docs Ready Ready Preview Comment Dec 12, 2025 3:31pm
2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
multisig-toolkit Ignored Ignored Preview Dec 12, 2025 3:31pm
sui-kiosk Ignored Ignored Preview Dec 12, 2025 3:31pm

@tpham-mysten tpham-mysten temporarily deployed to sui-typescript-aws-kms-test-env December 10, 2025 22:06 — with GitHub Actions Inactive
pub(crate) async fn version(&self, ctx: &Context<'_>) -> Result<Option<UInt53>, RpcError> {
self.super_.version(ctx).await
pub(crate) async fn version(&self, ctx: &Context<'_>) -> Option<Result<UInt53, RpcError>> {
self.super_.version(ctx).await.ok()?
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

.ok() is needed because async-graphql's #[Object] macro wraps method returns in Result<_, async_graphql::Error>. When calling a parent's #[Object] method (e.g., self.super_.version(ctx)), the actual return type becomes Result<Option<Result<T, E>>, Error> instead of Option<Result<T, E>>. Using .ok()? discards the outer wrapper and propagates None if the call failed.

Copy link
Copy Markdown
Contributor

@amnn amnn left a comment

Choose a reason for hiding this comment

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

Looks good, it would be nice to use a pattern similar to let Some(...) = self.content(ctx) else { ... } which I've suggested, but that's the only main comment. Thanks @tpham-mysten !

Copy link
Copy Markdown
Contributor Author

@tpham-mysten tpham-mysten left a comment

Choose a reason for hiding this comment

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

Thanks for the review! I have updated to the pattern

let contents = match self.contents(ctx).await.transpose()? {
            Ok(contents) => contents,
            Err(e) => return Some(Err(e)),
 };

@tpham-mysten tpham-mysten merged commit 9e87d01 into main Dec 15, 2025
56 of 57 checks passed
@tpham-mysten tpham-mysten deleted the tpham-object-partial-error-graphql branch December 15, 2025 02:44
tpham-mysten added a commit that referenced this pull request Dec 30, 2025
…t [5/n] (#24684)

## Description 

Add partial error support for GraphQL resolvers in
sui-indexer-alt-graphql by changing return types from Result<Option<T>,
E> to Option<Result<T, E>> for MoveModule and MovePackage types.

## Test plan 

How did you test the new or updated feature?

```
cargo nextest run -p sui-indexer-alt-e2e-tests
```

---

## Stack:
- #24595
- #24681 
- #24682 
- #24683 
- #24684 ⬅️

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [x] GraphQL: Partial error will be properly supported in GraphQL.
Invalid fields will have error messages and valid fields will still be
displayed normally
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] Indexing Framework:
tpham-mysten added a commit that referenced this pull request Dec 30, 2025
…n] (#24683)

## Description 

Add partial error support for GraphQL resolvers in
sui-indexer-alt-graphql by changing return types from Result<Option<T>,
E> to Option<Result<T, E>> for Epoch, Checkpoint, and Validator types.

## Test plan 

How did you test the new or updated feature?

```
cargo nextest run -p sui-indexer-alt-e2e-tests
```

---

## Stack
- #24595
- #24681 
- #24682 
- #24683 ⬅️
- #24684 

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [x] GraphQL: Partial error will be properly supported in GraphQL.
Invalid fields will have error messages and valid fields will still be
displayed normally
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] Indexing Framework:
tpham-mysten added a commit that referenced this pull request Dec 30, 2025
…rt [3/n] (#24682)

## Description 

Add partial error support for GraphQL resolvers in
sui-indexer-alt-graphql by changing return types from Result<Option<T>,
E> to Option<Result<T, E>> for Transaction-related types.

## Test plan 

How did you test the new or updated feature?

```
cargo nextest run -p sui-indexer-alt-e2e-tests
```

---

# Stack:
- #24595
- #24681 
- #24682 ⬅️
- #24683 
- #24684 

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [x] GraphQL: Partial error will be properly supported in GraphQL.
Invalid fields will have error messages and valid fields will still be
displayed normally
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] Indexing Framework:
tpham-mysten added a commit that referenced this pull request Dec 31, 2025
…ort [2/n] (#24681)

## Description 
Enable partial error support in sui-indexer-alt-graphql by changing GraphQL resolver return types from `Result<Option<T>, E>` to `Option<Result<T, E>>.`

- Before: When a field returns an error, the entire parent object becomes null
- After: When a field returns an error, only that specific field becomes null while sibling fields still return data

Changes

Pattern Migration

Changed ~30 files to use the Option<Result<T, E>> pattern with two main approaches:

  1. Async block with transpose: For complex async operations
  async fn field(&self) -> Option<Result<T, RpcError>> {
      async { ... Ok(Some(value)) }.await.transpose()
  }
  2. Simple wrapping: For infallible cases
  async fn field(&self) -> Option<Result<T, RpcError>> {
      Some(Ok(value))
  }

Files Modified
  - Core types: object.rs, address.rs, move_type.rs, move_value.rs, dynamic_field.rs
  - Transaction types: transaction/mod.rs, transaction_effects.rs, gas_input.rs
  - Move types: move_module.rs, move_function.rs, move_datatype.rs, move_package.rs,
  move_object.rs
  - Epoch/Checkpoint: epoch.rs, checkpoint/mod.rs
  - Validator: validator.rs, validator_set.rs
  - Others: coin_metadata.rs, event/mod.rs, unchanged_consensus_object.rs, transaction_kind
  types

## Test plan 

How did you test the new or updated feature?

```
cargo nextest run -p sui-indexer-alt-e2e-tests
```

---

## Stack
- #24595
- #24681 
- #24682 
- #24683 
- #24684 

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [x] GraphQL: Partial error will be properly supported in GraphQL.
Invalid fields will have error messages and valid fields will still be
displayed normally
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] Indexing Framework:
tpham-mysten added a commit that referenced this pull request Jan 28, 2026
…port [6/n] (#25108)

## Description 

Updates ServiceConfig return types from Result<Option<T>, E> to
Option<Result<T, E>> for partial error support.

Files changed:
- crates/sui-indexer-alt-graphql/src/api/types/service_config.rs

## Test plan 

```
cargo nextest run -p sui-indexer-alt-e2e-tests
```

---

## Stack
- #24595
- #24681 
- #24682 
- #24683 
- #24684 
- #25108 ⬅️

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [x] GraphQL: Partial error will be properly supported in GraphQL.
Invalid fields will have error messages and valid fields will still be
displayed normally
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] Indexing Framework:
tpham-mysten added a commit that referenced this pull request Jan 30, 2026
… return types for partial error support [7/n] (#25109)

## Description 

Updates `IMoveObject` interface and its implementors (`MoveObject`,
`CoinMetadata`, `DynamicField`) return types from `Result<Option<T>, E>`
to `Option<Result<T, E>>` for partial error support.

Files changed:
  - crates/sui-indexer-alt-graphql/src/api/types/move_object.rs
  - crates/sui-indexer-alt-graphql/src/api/types/coin_metadata.rs
  - crates/sui-indexer-alt-graphql/src/api/types/dynamic_field.rs

## Test plan 

How did you test the new or updated feature?

```
cargo nextest run -p sui-indexer-alt-e2e-tests
```

---

## Stack
- #24595
- #24681 
- #24682 
- #24683 
- #24684 
- #25108 
- #25109 ⬅️

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [x] GraphQL: Partial error will be properly supported in GraphQL.
Invalid fields will have error messages and valid fields will still be
displayed normally
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] Indexing Framework:
tpham-mysten added a commit that referenced this pull request Jan 30, 2026
…n] (#25110)

## Description 

Updates `Query` return types from `Result<Option<T>, E>` to
`Option<Result<T, E>>` for partial error support.

Files changed:
  - crates/sui-indexer-alt-graphql/src/api/query.rs

## Test plan 

How did you test the new or updated feature?

```
cargo nextest run -p sui-indexer-alt-e2e-tests
```

---

- #24595
- #24681 
- #24682 
- #24683 
- #24684 
- #25108 
- #25109
- #25110 ⬅️

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [x] GraphQL: Partial error will be properly supported in GraphQL.
Invalid fields will have error messages and valid fields will still be
displayed normally
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] Indexing Framework:
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.

2 participants