All pages
Powered by GitBook
1 of 6

Subgraph Manual

Manage Subgraph

This section will guide you on how to manage a subgraph.

  • Create Subgraph

  • Deploy Subgraph

  • Query Subgraph

  • Delete Subgraph


Create Subgraph

The node needs to be in the live state for you to add a subgraph to it.

Step 1: Graph Nodes - Navigate to the Graph Nodes page on the platform. Here you will see a list of nodes that you purchased and the ones that are already deployed. Now, click on the Add Subgraph button.

Step 2: Create Subgraph - Choose the Create New option from the dropdown menu.

Step 3: Enter Details - Provide a name, and choose the node and the network for your subgraph. Now, click on the Add button to create a new subgraph. NOTE: If only one node is live then it will be pre-selected. Also, if a single network is present in the node then it will also be pre-selected.

On successful creation, you will be redirected to the subgraph detail page.


Deploy Subgraph

Step 1: Navigate to the Details section on the subgraph detail page. Now, click on the Deployment Command button.

Step 2: Follow the steps provided on the screen to deploy your own subgraph.


Query Subgraph

The subgraph must be deployed and indexed before it can be queried.

On the subgraph detail page, navigate to the Query URL section. Click on first icon to open the GraphiQL query editor on a new tab, or click on second icon to copy the query URL.


Delete Subgraph

On the subgraph detail page, click on the Delete button on the top right corner of the screen.

Now, click on the Continue button to delete the subgraph.

Webhook Management

The Webhook addon service needs to be enabled on the node for you to use webhooks.

Follow the guide to manage the Webhook addon service here.

Webhook management is only possible for deployed subgraphs.

This section will guide you on how to manage your webhooks.

  • Create Webhook

  • Update Webhook

  • Undelivered Records

  • Delete Webhook

Handle Incoming Webhook Data

When configuring a webhook, it is imperative that the URL specified is capable of handling POST requests.

API Request Retry Policy

When initiating a request to a specified URL, the system will automatically attempt to connect up to three times at 30-minute intervals.

If, after three attempts, the URL remains unreachable, the data will be classified as an undelivered record.

Sample data payload that will be sent to the provided URL.

{
  "data": [
    {
      "id": "\\x1af00600",
      "vid": 50,
      "hour": 454682,
      "block$": 56200,
      "protocol": "\\x4200000000000000000000000000000000000010",
      "timestamp": 1636856051,
      "block_number": 56200,
      "cumulative_transaction_count": 1621,
      "cumulative_transfer_in_count": 1440,
      ...
    },
    {
      ...
    },
    {
      ...
    }
  ]
}

Create Webhook

On the subgraph detail page, navigate to the Webhooks section. Now, click on the '+' icon.

In the window that appears, choose the entities for whom you want to enable webhooks. Then, type in the URL of the location where you want the data for these entities to be sent.

Now, click the Create button to create webhooks for the selected entities.


Update Webhook

On the subgraph detail page, navigate to the Webhooks section.

Now, click the View Details button next to the entity you want to update.

On the window that appears, click the Edit button.

Update the required fields and then click on the Update button for the changes to take place.


Undelivered Records

On the subgraph detail page, navigate to the Webhooks section. Then, click the View Details button next to the entity you want to check for undelivered records.

On the window that appears, navigate to the Undelivered Records section.

In case, there are no undelivered records, the following message will be displayed.

If undelivered records are present then you can access them and try again to get them delivered by clicking on the Try Again button.


Delete Webhook

On the subgraph detail page, navigate to the Webhooks section. Now, click the Delete button against the entity for whom you want to delete the webhook and stop receiving updates.

Now, click on the Delete button to delete the webhook.

NOTE: In case you want to remove all webhooks from the subgraph, click the Delete All button at the top right.

Now, click the Delete button to delete all the webhooks.

Index Data Pruning

Subgraphs, by default, store a full version history for entities, allowing consumers to query the subgraph as of any historical block. Index Data Pruning is an operation that deletes entity versions from a subgraph older than a certain block, so it is no longer possible to query the subgraph as of prior blocks. In GraphQL, those are only queries with a constraint block { number: <n> } } or a similar constraint by block hash where n is before the block to which the subgraph is pruned. Queries that are run at a block height greater than that are not affected by pruning, and there is no difference between running these queries against an unpruned and a pruned subgraph.

History Blocks setting which is used to periodically check whether the subgraph has accumulated more history than that. Whenever the subgraph does contain more history than that, the subgraph is automatically repruned. Repruning is performed whenever the subgraph has more than History Blocks * 1.8 blocks of history.

Manage Index Data Pruning On Subgraph

Step 1: Purchase Index Data Pruning addons by navigating to Graph Nodes Purchase.

Refer Purchase Subscription page for more details.

Step 2: To enable the Storage & Query Optimizer addon service, navigate to the specific node where it needs to be enabled.

Refer Manage Addon Services page for more details.

Step 3: Select a subgraph to navigate to its details page, then click on the Index Data Pruning tab. This section display Index Data Pruning configuration for the respective subgraph.

Configure Pruning

Before configuring index pruning, ensure the subgraph is deployed.

To configure index data pruning for a subgraph, follow these steps:

  1. Click the Configure Pruning button, a modal window will appear.

  2. Set desired History Blocks. ( The minimum value must be set at 500, while the maximum value should align with the current block of the subgraph. )

  3. To prune once, select the Prune Once checkbox (Repruning will not occur); otherwise, leave it unselected.

  4. Click the Confirm button to configure index data pruning, or click Close button to dismiss the modal without making changes.

This will initiate the process to configure index data pruning on the subgraph.

Once the index data pruning is configured you will be notified via in-app notification and see this on the dashboard.

Deconfigure Pruning

To deconfigure index data pruning for a subgraph, follow these steps:

  1. Click the Deconfigure button, a modal window will appear.

  2. Click the Yes button to deconfigure index data pruning, or click No button to dismiss the modal.

Settings

Manage Settings

Step 1: Register/Login - Create a new account or log in to your existing account on the Traceye Platform.

Step 2: Navigate to Graph Nodes - Click on the Graph Nodes in the DEDICATED INDEXING section on the left navigation panel.

Step 3: You will be redirected to the Graph Nodes screen to view a list of all existing nodes and their respective subgraphs.

Step 4: Select a subgraph to navigate to its details page, then click on the Settings tab. This section displays all your configured settings.

Step 5: To apply new settings, adjust them as needed and then click Save Button to confirm your changes.

Setting Types

Notifications

Subgraph notifications are a pivotal feature for users who rely on subgraph data for their applications or analyses. These notifications are designed to inform users about significant changes and milestones in the lifecycle of a subgraph, enhancing the overall user experience by ensuring critical updates are timely communicated. Here are the main scenarios where notifications are triggered:

Subgraph Status

Notifications are sent out once the status of a subgraph changes to 'Healthy', 'Unhealthy', or 'Failed'. This feature is crucial for maintaining the reliability and performance of applications that depend on subgraph data.

Completely Synced

Notifications are sent out once a subgraph has fully synced with the blockchain. This ensures that users are aware of when the data from a subgraph is up to date and reflects the latest state of the blockchain._

Query Ready

Notifications are sent out once the subgraph are ready to be queried, ensuring that they can leverage the latest data and information immediately.

Implementing these notifications helps users monitor their subgraphs effectively, reducing the need for manual checks and enabling more efficient management of their applications or data analyses.

You will receive notifications both in-app and via email.

Substreams-Powered Subgraphs

An internet connection is required for generating Rust bindings.

  1. Direct Download

LINK=$(curl -s https://api.github.com/repos/bufbuild/buf/releases/latest | \
awk "/download.url.*buf-Linux-$(uname -m)\"/ {print \$2}" | sed 's/"//g')

echo Downloading $LINK

curl -L $LINK -o /usr/bin/buf
  1. Using npm

npm install @bufbuild/buf

Rust

A complete Rust environment is necessary for developing Substreams modules.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

source $HOME/.cargo/env

Create Substreams-Powered Subgraphs

There are two methods of creating Substreams-Powered Subgraphs:

  1. Using Substreams triggers: Consume from any Substreams module by importing the Protobuf model through a Subgraph handler and move all your logic into a Subgraph. This method creates the Subgraph entities directly in the Subgraph.

  2. Using Entity Changes⁠: By writing more of the logic into Substreams, you can consume the module’s output directly into Subgraph. In Subgraph you can use the Substreams data to create your Subgraph entities.

You can choose where to place your logic, either in the Subgraph or Substreams. However, consider what aligns with your data needs, as Substreams has a parallelized model, and triggers are consumed linearly.

Deploy Substreams-Powered Subgraphs

Before deploying a substream-powered subgraph, ensure substream are enabled for the blockchain network in Graph Node.

  1. Add Rust Target

rustup target add wasm32-unknown-unknown
  1. Generate Protobuf Types

substreams protogen

This command generates types in /src/pb.

  1. Build Substreams

substreams build

This command creates a Substream package (.spkg), which can be used as a data source for a subgraph to access pre-indexed blockchain data streams.

  1. Generate Subgraph Project

substreams codegen subgraph
  1. Navigate to the Subgraph Directory

Edit the following files as needed:

  • mappings.ts

  • schema.graphql

  • subgraph.yaml

  1. Install Dependencies

npm install
  1. Generate AssemblyScript & Protobuf Bindings

npm run generate
  1. Build Subgraph

npm run build

The final step is to deploy the subgraph using the deployment command. See Manage Subgraph