Graphql SDK
Installation
bun add @inverter-network/graphqlInitializing the Graphql SDK
import { Client } from '@inverter-network/graphql'
const devUrl = 'https://dev.indexer.inverter.network/v1/graphql'
const prodUrl = 'https://indexer.inverter.network/v1/graphql'
Client.updateUrl(devUrl) // By default the Client uses `prodUrl`Subscribing and Querying
import { type GraphQLQueryArgs, query, subscription } from '@inverter-network/graphql'
const fields = {
Token: {
__args: {
where: {
address: {
_eq: '0x961bB3932A7efAa9aDcc7409e1fea090479E8312',
},
chainId: {
_eq: 1101,
},
},
},
chainId: 1,
address: 1,
name: 1,
decimals: 1,
symbol: 1,
totalSupply: 1,
},
} as const satisfies GraphQLQueryArgs
// Query
const tokens = await query(fields)
// Subscription
const sub = subscription(fields)
// You can add as many callbacks to a subscription
sub.addCallback((data) => {
console.log(data)
})Last updated