@onelabs/graphql-transport v0.2.48
@onelabs/graphql-transport
This package provides a SuiTransport that enables SuiClient to make requests using the RPC 2.0
(GraphQL) API instead of the JSON RPC API.
Install
npm install --save @onelabs/graphql-transportSetup
import { SuiClientGraphQLTransport } from '@onelabs/graphql-transport';
import { getFullnodeUrl, SuiClient } from '@onelabs/sui/client';
const client = new SuiClient({
transport: new SuiClientGraphQLTransport({
url: 'https://sui-testnet.mystenlabs.com/graphql',
// When specified, the transport will fallback to JSON RPC for unsupported method and parameters
fallbackFullNodeUrl: getFullnodeUrl('testnet'),
}),
});Limitations
Unsupported methods
The following methods are currently unsupported in SuiClientGraphQLTransport, and will either error,
or fallback to the JSON RPC API if a fallbackFullNodeUrl is provided:
subscribeTransactionsubscribeEventscallgetNetworkMetricsgetMoveCallMetricsgetAddressMetricsgetEpochsdryRunTransactionBlockdevInspectTransactionBlockexecuteTransactionBlock
Unsupported parameters
Some supported methods in SuiClientGraphQLTransport do not support the full set of parameters
available in the JSON RPC API.
If an unsupported parameter is used, the request will error, or fallback to JSON RPC API if a
fallbackFullNodeUrl is provided.
getOwnedObjects:- missing the
MatchAll,MatchAny,MatchNone, andVersionfilters
- missing the
queryEvents:- missing the
MoveEventField,Module,TimeRange,All,Any,And, andOrfilters
- missing the
Unsupported fields
queryTransactionBlocks,getTransactionBlock, andmultiGetTransactionBlocks- missing
messageVersion,eventsDigest,sharedObjects,unwrapped,wrapped, andunwrappedThenDeletedin effects - missing
idforevents
- missing
getStakesandgetStakesByIds- missing
validatorAddress
- missing
getLatestSuiSystemState- missing
stakingPoolMappingsId,inactivePoolsId,pendingActiveValidatorsId,validatorCandidatesId - missing
reportRecordson validators
- missing
getCurrentEpoch- missing
reportRecordson validators
- missing
queryEvents- missing
idforevents
- missing
getCheckpointandgetCheckpoints- missing
checkpointCommitments
- missing
getCurrentEpoch- missing
epochTotalTransactions
- missing
getDynamicFields- missing
objectId,digestandversionavailable forDynamicObjectbut notDynamicField
- missing
Performance
Some may require multiple requests to properly resolve:
getDynamicFieldObjectrequires 2 requestsqueryTransactionBlocks,getTransactionBlock, andmultiGetTransactionBlocks- may require additional requests to load all
objectChanges,balanceChanges,dependenciesandevents
- may require additional requests to load all
getNormalizedMoveModuleandgetNormalizedMoveModulesByPage- may require additional requests to load all
friends,functions, andstructs
- may require additional requests to load all
getCheckpointandgetCheckpoints,- may require additional requests to load all
transactionBlocksandvalidators
- may require additional requests to load all
getLatestSuiSystemState,getCurrentEpoch,getValidatorsApyandgetCommitteeInfo:- may require additional requests to load all
validators
- may require additional requests to load all
Pagination
Page sizes and limits for paginated methods are based on the defaults and limits of the GraphQL API, so page sizes and limits may be different than those returned by the JSON RPC API