Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update links to the example-subgraph repo #175

Merged
merged 3 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Combine defining & creating pages
including redirect
  • Loading branch information
azf20 committed Jul 26, 2022
commit 359c6e975ae506e79c14541c19554447f1f469a1
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/

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.