From 531a6d721dfa4de199e4c6a9b2abe7e0c686113b Mon Sep 17 00:00:00 2001 From: ZCDC_Ren Date: Sat, 14 Dec 2024 06:28:32 +0800 Subject: [PATCH] [doc] fix: using-events graphql error (#20618) ## Description The GraphQL in [Query events with GraphQL](https://docs.sui.io/guides/developer/sui-101/using-events#query-events-with-graphql) has error ## Test plan 1. [crates/sui-graphql-rpc/examples/event_connection/event_connection.graphql](https://github.com/MystenLabs/sui/tree/main/crates/sui-graphql-rpc/examples/event_connection/event_connection.graphql) and [crates/sui-graphql-rpc/examples/event_connection/filter_by_sender.graphql](https://github.com/MystenLabs/sui/tree/main/crates/sui-graphql-rpc/examples/event_connection/filter_by_sender.graphql) throw the error ```json { "data": null, "errors": [ { "message": "Unknown field \"type\" on type \"Event\".", "locations": [ { "line": 18, "column": 7 } ] }, { "message": "Unknown field \"json\" on type \"Event\".", "locations": [ { "line": 25, "column": 7 } ] } ] } ``` need to be modified to ``` contents { type { repr } json } ``` 2. [crates/sui-graphql-rpc/examples/event_connection/filter_by_emitting_package_module_and_event_type.graphql](https://github.com/MystenLabs/sui/tree/main/crates/sui-graphql-rpc/examples/event_connection/filter_by_emitting_package_module_and_event_type.graphql) throw the error ```json { "data": null, "errors": [ { "message": "Filtering by both emitting module and event type is not supported", "locations": [ { "line": 2, "column": 3 } ], "path": [ "events" ], "extensions": { "code": "BAD_USER_INPUT" } } ] } ``` Read the [EventFilter.emittingModule doc](https://docs.sui.io/references/sui-api/sui-graphql/reference/types/inputs/event-filter#eventfilteremittingmodulestring-), it says `We currently do not support filtering by emitting module and event type at the same time so if both are provided in one filter, the query will error.`. So I think the doc need to delete the example `[Filter events by emitting package and type]` --- ## 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): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --- .../event_connection/event_connection.graphql | 12 ++++---- ...ting_package_module_and_event_type.graphql | 29 ------------------- .../event_connection/filter_by_sender.graphql | 8 +++-- .../guides/developer/sui-101/using-events.mdx | 7 ----- 4 files changed, 12 insertions(+), 44 deletions(-) delete mode 100644 crates/sui-graphql-rpc/examples/event_connection/filter_by_emitting_package_module_and_event_type.graphql diff --git a/crates/sui-graphql-rpc/examples/event_connection/event_connection.graphql b/crates/sui-graphql-rpc/examples/event_connection/event_connection.graphql index 5a9f5bae4d8f8..6fb683c37e5f4 100644 --- a/crates/sui-graphql-rpc/examples/event_connection/event_connection.graphql +++ b/crates/sui-graphql-rpc/examples/event_connection/event_connection.graphql @@ -9,15 +9,17 @@ name package { digest } } - type { - repr - } sender { address } timestamp - json + contents { + type { + repr + } + json + } bcs } } -} +} \ No newline at end of file diff --git a/crates/sui-graphql-rpc/examples/event_connection/filter_by_emitting_package_module_and_event_type.graphql b/crates/sui-graphql-rpc/examples/event_connection/filter_by_emitting_package_module_and_event_type.graphql deleted file mode 100644 index b1df6c65f06cc..0000000000000 --- a/crates/sui-graphql-rpc/examples/event_connection/filter_by_emitting_package_module_and_event_type.graphql +++ /dev/null @@ -1,29 +0,0 @@ -query ByEmittingPackageModuleAndEventType { - events( - first: 1 - after: "eyJ0eCI6Njc2MywiZSI6MCwiYyI6MjI4MDA3NDJ9" - filter: { - emittingModule: "0x3::sui_system", - eventType: "0x3::validator::StakingRequestEvent" - } - ) { - pageInfo { - hasNextPage - endCursor - } - nodes { - sendingModule { - name - } - type { - repr - } - sender { - address - } - timestamp - json - bcs - } - } -} diff --git a/crates/sui-graphql-rpc/examples/event_connection/filter_by_sender.graphql b/crates/sui-graphql-rpc/examples/event_connection/filter_by_sender.graphql index 7ba8047037532..72d97b9248dc4 100644 --- a/crates/sui-graphql-rpc/examples/event_connection/filter_by_sender.graphql +++ b/crates/sui-graphql-rpc/examples/event_connection/filter_by_sender.graphql @@ -13,14 +13,16 @@ query ByTxSender { sendingModule { name } - type { - repr + contents { + type { + repr + } + json } sender { address } timestamp - json bcs } } diff --git a/docs/content/guides/developer/sui-101/using-events.mdx b/docs/content/guides/developer/sui-101/using-events.mdx index c2b5c1887d573..dce9ac24efbc2 100644 --- a/docs/content/guides/developer/sui-101/using-events.mdx +++ b/docs/content/guides/developer/sui-101/using-events.mdx @@ -311,13 +311,6 @@ Filter events by sender {@inject: crates/sui-graphql-rpc/examples/event_connection/filter_by_sender.graphql} -
- -Filter events by emitting package and type - -{@inject: crates/sui-graphql-rpc/examples/event_connection/filter_by_emitting_package_module_and_event_type.graphql} -
- The [TypeScript SDK](https://sdk.mystenlabs.com/typedoc/modules/_mysten_sui.graphql.html) provides functionality to interact with the Sui GraphQL service. ## Monitoring events