# @astralprotocol/subgraph

> The @astralprotocol/subgraph serves as the indexing engine of the protocol, capturing the registration and modification events of GeoDIDs in the @astralprotocol/contracts. It acts like a decentralized querying database where it is substantially easier to

Latest version **1.0.13** (published 2021-03-29) · MIT OR Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @astralprotocol/subgraph
pnpm add @astralprotocol/subgraph
yarn add @astralprotocol/subgraph
bun add @astralprotocol/subgraph
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2021-03-29 |
| First published | 2021-01-05 |
| Weekly downloads | 0 |
| License | MIT OR Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Astral |
| Maintainers | astralprotocol |

## Links

- npm: https://www.npmjs.com/package/@astralprotocol/subgraph
- Repository: https://github.com/AstralProtocol/astralprotocol
- Homepage: https://github.com/AstralProtocol/astralprotocol#readme
- Issues: https://github.com/AstralProtocol/astralprotocol/issues
- npm.io page: https://npm.io/package/@astralprotocol/subgraph

## Dependencies (2)

- [@graphprotocol/graph-ts](https://npm.io/package/@graphprotocol/graph-ts.md) ^0.19.0
- [@graphprotocol/graph-cli](https://npm.io/package/@graphprotocol/graph-cli.md) ^0.19.0

## Recent versions

- 1.0.13 (latest) — 2021-03-29
- 1.0.11 — 2021-03-28
- 1.0.9 — 2021-03-17
- 1.0.8 — 2021-03-16
- 1.0.5 — 2021-02-25
- 1.0.4 — 2021-02-24
- 1.0.3 — 2021-02-24
- 1.0.2 — 2021-02-24
- 1.0.1 — 2021-02-24
- 0.1.5 — 2021-02-23
- 0.1.4 — 2021-02-18
- 0.1.3 — 2021-02-18
- 0.0.2 — 2021-02-09
- 0.0.1 — 2021-01-05

## README

# @astralprotocol/subgraph

## Description

The @astralprotocol/subgraph serves as the indexing engine of the protocol, capturing the registration and modification events of GeoDIDs in the @astralprotocol/contracts. It acts like a decentralized querying database where it is substantially easier to make complex queries to the Spatial Assets registry. It is used to create the tree of GeoDID nodes that represents their relationships and groupings.

The current version of the subgraph (v06) is indexing the Ethereum Roptsten network at the following graphql endpoints:

- `https://api.thegraph.com/subgraphs/name/astralprotocol/spatialassetsv06`
- `wss://api.thegraph.com/subgraphs/name/astralprotocol/spatialassetsv06`

You can connect to these with your GraphQL client of choice.

## To add Astral Protocol Subgraph to your application

```
yarn add @astralprotocol/subgraph
```

## To develop or try the Astral Protocol Subgraph locally

### Prerequisites

- Clone the astralprotocol repository and go to packages/subgraph
- Run `sudo apt-get install libsecret-1-dev`
- [Docker Instalation](https://docs.docker.com/install/linux/docker-ce/debian/)
- Run `git clone https://github.com/graphprotocol/graph-node/` (check setup instructions for docker version on https://thegraph.com/docs/)
- Have the development steps of @astralprotocol/contracts done previously (with Ganache)

### Deployment

1. Ensure you have ganache running with the contracts deployed from packages/contracts
2. Update the SpatialAssets contract address that you got from the previous step in the subgraph.yaml (if needed and ensure the correct file is named according to the network of deployment - for ganache it should read as mainnet: backup the current subgraph.yamlfile and rename it to subgraphRopsten.yaml).
3. In another terminal, inside the graph-node folder, run `cd docker && docker-compose up`. If using Docker for WSL, Docker must be running on Windows. If graph-node throws an error try clearing the `data/postgres` folder, within the docker directory of graph-node, with `sudo rm -rf data/postgres`. Restart docker if needed and you are using WSL.
4. Generate subgraph typescript files with `yarn codegen`, then create and deploy the subgraph to the graph-node with `yarn create-local && yarn deploy-local`
5. You can query the subgraph and view the GeoDID tree in the local provided endpoint.

### Testing

The following query can be provided to the graphql endpoint to view the GeoDIDs tree (after doing the deployment steps above):

```
{
  geoDIDs {
    id
    owner
    cid
    storage
    root
    parent
    edges {
      id
      childGeoDID {
        id
      }
    }
    active
    type
  }
}
```

---
_Source: https://npm.io/package/@astralprotocol/subgraph · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
