Skip to content

Commit 4c10c42

Browse files
authored
Combine created and defined (#176)
* Update links to the example-subgraph repo * Combine defining & creating pages including redirect * Revert "Update links to the example-subgraph repo" This reverts commit 175f97a. * add permanent
1 parent 84ba4eb commit 4c10c42

File tree

3 files changed

+33
-37
lines changed

3 files changed

+33
-37
lines changed

nginx.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ http {
8383
rewrite ^/docs/([a-zA-Z][a-zA-Z])/supported-networks/arweave/$ $scheme://$http_host/docs/$1/cookbook/arweave/ permanent;
8484
rewrite ^/docs/([a-zA-Z][a-zA-Z])/supported-networks/cosmos/$ $scheme://$http_host/docs/$1/cookbook/cosmos/ permanent;
8585
rewrite ^/docs/([a-zA-Z][a-zA-Z])/supported-networks/near/$ $scheme://$http_host/docs/$1/cookbook/near/ permanent;
86+
rewrite ^/docs/([a-zA-Z][a-zA-Z])/developing/defining-a-subgraph/$ $scheme://$http_host/docs/$1/developing/creating-a-subgraph/ permanent;
8687

8788
location / {
8889
try_files $uri $uri.html $uri/index.html =404;

pages/en/developing/creating-a-subgraph.mdx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,39 @@
22
title: Creating a Subgraph
33
---
44

5-
Before being able to use the Graph CLI, you need to create your subgraph in [Subgraph Studio](https://thegraph.com/studio). You will then be able to setup your subgraph project and deploy it to the platform of your choice. Note that **subgraphs that do not index Ethereum mainnet will not be published to The Graph Network**.
5+
A subgraph extracts data from a blockchain, processing it and storing it so that it can be easily queried via GraphQL.
66

7-
The `graph init` command can be used to set up a new subgraph project, either from an existing contract on any of the public Ethereum networks or from an example subgraph. This command can be used to create a subgraph on the Subgraph Studio by passing in `graph init --product subgraph-studio`. If you already have a smart contract deployed to Ethereum mainnet or one of the testnets, bootstrapping a new subgraph from that contract can be a good way to get started.
7+
![Defining a Subgraph](/img/defining-a-subgraph.png)
8+
9+
The subgraph definition consists of a few files:
10+
11+
- `subgraph.yaml`: a YAML file containing the subgraph manifest
12+
13+
- `schema.graphql`: a GraphQL schema that defines what data is stored for your subgraph, and how to query it via GraphQL
14+
15+
- `AssemblyScript Mappings`: [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) code that translates from the event data to the entities defined in your schema (e.g. `mapping.ts` in this tutorial)
16+
17+
Before you go into detail about the contents of the manifest file, you need to install the [Graph CLI](https://github.com/graphprotocol/graph-cli) which you will need to build and deploy a subgraph.
18+
19+
## Install the Graph CLI
20+
21+
The Graph CLI is written in JavaScript, and you will need to install either `yarn` or `npm` to use it; it is assumed that you have yarn in what follows.
22+
23+
Once you have `yarn`, install the Graph CLI by running
24+
25+
**Install with yarn:**
26+
27+
```bash
28+
yarn global add @graphprotocol/graph-cli
29+
```
30+
31+
**Install with npm:**
32+
33+
```bash
34+
npm install -g @graphprotocol/graph-cli
35+
```
36+
37+
Once installed, the `graph init` command can be used to set up a new subgraph project, either from an existing contract on any of the public Ethereum networks or from an example subgraph. This command can be used to create a subgraph on the Subgraph Studio by passing in `graph init --product subgraph-studio`. If you already have a smart contract deployed to Ethereum mainnet or one of the testnets, bootstrapping a new subgraph from that contract can be a good way to get started.
838

939
## From An Existing Contract
1040

pages/en/developing/defining-a-subgraph.mdx

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)