Skip to content

Commit

Permalink
Combine created and defined (#176)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
azf20 authored Jul 27, 2022
1 parent 84ba4eb commit 4c10c42
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
1 change: 1 addition & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ http {
rewrite ^/docs/([a-zA-Z][a-zA-Z])/supported-networks/arweave/$ $scheme://$http_host/docs/$1/cookbook/arweave/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/supported-networks/cosmos/$ $scheme://$http_host/docs/$1/cookbook/cosmos/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/supported-networks/near/$ $scheme://$http_host/docs/$1/cookbook/near/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/developing/defining-a-subgraph/$ $scheme://$http_host/docs/$1/developing/creating-a-subgraph/ permanent;

location / {
try_files $uri $uri.html $uri/index.html =404;
Expand Down
34 changes: 32 additions & 2 deletions pages/en/developing/creating-a-subgraph.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,39 @@
title: Creating a Subgraph
---

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**.
A subgraph extracts data from a blockchain, processing it and storing it so that it can be easily queried via GraphQL.

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.
![Defining a Subgraph](/img/defining-a-subgraph.png)

The subgraph definition consists of a few files:

- `subgraph.yaml`: a YAML file containing the subgraph manifest

- `schema.graphql`: a GraphQL schema that defines what data is stored for your subgraph, and how to query it via GraphQL

- `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)

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.

## Install the Graph CLI

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.

Once you have `yarn`, install the Graph CLI by running

**Install with yarn:**

```bash
yarn global add @graphprotocol/graph-cli
```

**Install with npm:**

```bash
npm install -g @graphprotocol/graph-cli
```

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.

## From An Existing Contract

Expand Down
35 changes: 0 additions & 35 deletions pages/en/developing/defining-a-subgraph.mdx

This file was deleted.

0 comments on commit 4c10c42

Please sign in to comment.