Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: examples of things only GraphQL can do #19668

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion docs/content/guides/developer/advanced/graphql-migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,49 @@ The cursor is now passed in the `after` (or `before`) fields on the connection,
</TabItem>
</Tabs>

## New features

There are also things that GraphQL can do, which JSON-RPC cannot:

### Example 4: Getting objects by type

This query fetches the latest versions of objects of type `0x2::package::Publisher` that are currently live on-chain.

```graphql
query {
objects(filter: { type: "0x2::package::Publisher" }) {
nodes {
address
digest
asMoveObject {
contents { json }
}
}
}
}
```

### Example 5: Paging through package versions

The goal is to find all versions of the Sui framework, and list their modules:

```graphql
query {
packageVersions(address: "0x2") {
nodes {
version
modules {
nodes {
name
}
}
}
}
}
```

## Related links

- [GraphQL reference](../../../references/sui-graphql.mdx): Auto-generated GraphQL reference for Sui RPC.
- [GraphQL quick-start](../getting-started/graphql-rpc.mdx): Querying Sui RPC with GraphQL gets you started using GraphQL to query the Sui RPC for on-chain data.
- [GraphQL concepts](../../../concepts/graphql-rpc.mdx): GraphQL for Sui RPC examines the elements of GraphQL that you should know to get the most from the service.
- [GraphQL concepts](../../../concepts/graphql-rpc.mdx): GraphQL for Sui RPC examines the elements of GraphQL that you should know to get the most from the service.
Loading