@analog-labs/timegraph-js
v0.1.7
Published
A typed GraphQL API wrapper for fetching and creating resources on [Analog Timegraph](https://github.com/analog-labs/timegraph-sdk).
Downloads
553
Keywords
Readme
@analog-labs/timegraph-js
A typed GraphQL API wrapper for fetching and creating resources on Analog Timegraph.
Usage
import { TimegraphClient } from '@analog-labs/timegraph-js';
async function useTimegraphClient(){
// Instantiate
const client = new TimegraphClient({
url: 'https://timegraph.testnet.analog.one/graphql',
sessionKey: '0;2Evg4riXZjyK3...'
});
// Get a specific view detail
const getView = await client.view.get({ hashId: 'QmfVym1oXGXpidFEd1sRkCGJSfuzC2V5TpK3Qp5pyXhWnM' });
// Alias another user's view to your own subgraph
const aliasView = await client.alias.add({ hashId: 'QmfVym1oXGXpidFEd1sRkCGJSfuzC2V5TpK3Qp5pyXhWnM', name: "view_name" });
// Query a view
const queryView = await client.view.data({
_name: "view_name",
fields: ["_clock", "_index", "name"],
limit: 10
});
// Publish a new view
const createView = await client.view.create({
view: {
identifier: "unique_identifier",
name: "view_name",
description: "description should be between 20 to 273 char",
sql: "SELECT a._clock, a._index ...",
tags: ["Defi", "ERC20"]
}
});
}
useTimegraphClient();