https://github.com/automata-network/subquery
https://github.com/automata-network/subquery
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/automata-network/subquery
- Owner: automata-network
- License: mit
- Created: 2022-02-17T03:35:56.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-24T06:44:44.000Z (over 2 years ago)
- Last Synced: 2025-02-17T16:45:02.243Z (3 months ago)
- Language: TypeScript
- Size: 290 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SubQuery - Starter Package
The Starter Package is an example that you can use as a starting point for developing your SubQuery project.
A SubQuery package defines which data The SubQuery will index from the Substrate blockchain, and how it will store it.## Preparation
#### Environment
- [Typescript](https://www.typescriptlang.org/) are required to compile project and define types.
- Both SubQuery CLI and generated Project have dependencies and require [Node](https://nodejs.org/en/).
#### Install the SubQuery CLI
Install SubQuery CLI globally on your terminal by using NPM:
```
npm install -g @subql/cli
```Run help to see available commands and usage provide by CLI
```
subql help
```## Initialize the starter package
Inside the directory in which you want to create the SubQuery project, simply replace `project-name` with your project name and run the command:
```
subql init --starter project-name
```
Then you should see a folder with your project name has been created inside the directory, you can use this as the start point of your project. And the files should be identical as in the [Directory Structure](https://doc.subquery.network/directory_structure.html).Last, under the project directory, run following command to install all the dependency.
```
yarn install
```## Configure your project
In the starter package, we have provided a simple example of project configuration. You will be mainly working on the following files:
- The Manifest in `project.yaml`
- The GraphQL Schema in `schema.graphql`
- The Mapping functions in `src/mappings/` directoryFor more information on how to write the SubQuery,
check out our doc section on [Define the SubQuery](https://doc.subquery.network/define_a_subquery.html)#### Code generation
In order to index your SubQuery project, it is mandatory to build your project first.
Run this command under the project directory.````
yarn codegen
````## Build the project
In order to deploy your SubQuery project to our hosted service, it is mandatory to pack your configuration before upload.
Run pack command from root directory of your project will automatically generate a `your-project-name.tgz` file.```
yarn build
```## Indexing and Query
#### Run required systems in docker
Under the project directory run following command:
```
docker-compose pull && docker-compose up
```
#### Query the projectOpen your browser and head to `http://localhost:3000`.
Finally, you should see a GraphQL playground is showing in the explorer and the schemas that ready to query.
For the `subql-starter` project, you can try to query with the following code to get a taste of how it works.
````graphql
{
query{
starterEntities(first:10){
nodes{
field1,
field2,
field3
}
}
}
}
````