-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Describe the changes or additions included in this PR. ## Test plan How did you test the new or updated feature? --- ## 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:
- Loading branch information
1 parent
aed4145
commit 1e05f91
Showing
42 changed files
with
1,036 additions
and
189 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
dapps/multisig-toolkit/src/components/preview-effects/EffectsPreview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dapps/multisig-toolkit/src/components/preview-effects/ObjectLink.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dapps/multisig-toolkit/src/components/preview-effects/PreviewCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dapps/multisig-toolkit/src/components/preview-effects/partials/Events.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dapps/multisig-toolkit/src/components/preview-effects/partials/ObjectChanges.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
dapps/multisig-toolkit/src/components/preview-effects/partials/Transactions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# SuiGraphQLClient | ||
|
||
import { Callout } from 'nextra/components'; | ||
|
||
<Callout type="warning"> | ||
SuiGraphQLClient is still in development and may change rapidly as it is being developed. | ||
</Callout> | ||
|
||
To support GraphQL Queries, the Typescript SDK includes the `SuiGraphQLClient` which can help you | ||
write and execute GraphQL queries against the Sui GraphQL API that are type-safe and easy to use. | ||
|
||
## Writing your first query | ||
|
||
We'll start by creating our client, and executing a very basic query: | ||
|
||
```typescript | ||
import { SuiGraphQLClient } from '@mysten/sui/graphql'; | ||
import { graphql } from '@mysten/sui/graphql/schemas/2024.4'; | ||
|
||
const gqlClient = new SuiGraphQLClient({ | ||
url: 'https://sui-testnet.mystenlabs.com/graphql', | ||
}); | ||
|
||
const chainIdentifierQuery = graphql(` | ||
query { | ||
chainIdentifier | ||
} | ||
`); | ||
|
||
async function getChainIdentifier() { | ||
const result = await gqlClient.query({ | ||
query: chainIdentifierQuery, | ||
}); | ||
|
||
return result.data?.chainIdentifier; | ||
} | ||
``` | ||
|
||
## Type-safety for GraphQL queries | ||
|
||
You may have noticed the example above does not include any type definitions for the query. The | ||
`graphql` function used in the example is powered by [`gql.tada`](https://gql-tada.0no.co/) and will | ||
automatically provide the required type information to ensure that your queries are properly typed | ||
when executed through `SuiGraphQLClient`. | ||
|
||
The `graphql` function itself is imported from a versioned schema file, and you should ensure that | ||
you are using the version that corresponds to the latest release of the GraphQL API. | ||
|
||
The `graphql` also detects variables used by your query, and will ensure that the variables passed | ||
to your query are properly typed. | ||
|
||
```typescript | ||
const getSuinsName = graphql(` | ||
query getSuiName($address: SuiAddress!) { | ||
address(address: $address) { | ||
defaultSuinsName | ||
} | ||
} | ||
`); | ||
|
||
async function getDefaultSuinsName(address: string) { | ||
const result = await gqlClient.query({ | ||
query: getSuinsName, | ||
variables: { | ||
address, | ||
}, | ||
}); | ||
|
||
return result.data?.address?.defaultSuinsName; | ||
} | ||
``` | ||
|
||
## Using typed GraphQL queries with other GraphQL clients | ||
|
||
The `graphql` function returns document nodes that implement the | ||
[TypedDocumentNode](https://github.com/dotansimha/graphql-typed-document-node) standard, and will | ||
work with the majority of popular GraphQL clients to provide queries that are automatically typed. | ||
|
||
```typescript | ||
import { useQuery } from '@apollo/client'; | ||
|
||
const chainIdentifierQuery = graphql(` | ||
query { | ||
chainIdentifier | ||
} | ||
`); | ||
|
||
function ChainIdentifier() { | ||
const { loading, error, data } = useQuery(getPokemonsQuery); | ||
|
||
return <div>{data?.chainIdentifier}</div>; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"sui-1.0": "@mysten/sui v1.0" | ||
} |
Oops, something went wrong.