-
Notifications
You must be signed in to change notification settings - Fork 155
Transfer to The Graph Cookbook #803
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
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fb497d4
Cookbook
idalithb 28b95f6
updated version
idalithb 8f3d55f
tiny edits
idalithb a9d591b
Update website/pages/en/cookbook/transfer-to-the-graph.mdx
idalithb e72811c
updating copy
idalithb a8537e3
updating
idalithb 14760aa
Adding to all lang & making final copy edits.
idalithb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
--- | ||
title: Tranfer to The Graph | ||
--- | ||
|
||
Learn how to quickly upgrade your subgraphs from any platform to [The Graph's decentralized network](https://thegraph.com/networks/). | ||
|
||
## Benefits of Switching to The Graph | ||
|
||
- Use the same subgraph that your apps already use with zero-downtime migration. | ||
- Increase reliability from a global network supported by 100+ Indexers. | ||
- Receive lightning-fast support for subgraphs 24/7, with an on-call engineering team. | ||
|
||
## Upgrade Your Subgraph to The Graph in 3 Easy Steps | ||
|
||
1. [Set Up Your Studio Environment](/cookbook/transfer-to-the-graph/#1-set-up-your-studio-environment) | ||
2. [Deploy Your Subgraph to Studio](/cookbook/transfer-to-the-graph/#2-deploy-your-subgraph-to-studio) | ||
3. [Publish to The Graph Network](/cookbook/transfer-to-the-graph/#publish-your-subgraph-to-the-graphs-decentralized-network) | ||
|
||
## 1. Set Up Your Studio Environment | ||
|
||
### Install the Graph CLI | ||
|
||
On your local machine, run the following commands: | ||
|
||
Using [npm](https://www.npmjs.com/): | ||
|
||
```sh | ||
graph init --product subgraph-studio | ||
``` | ||
|
||
> Alternatively, you can set up your environment using codespaces on your Github repo. | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Create a Subgraph in Subgraph Studio | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- Go to [Subgraph Studio](https://thegraph.com/studio/) and connect your wallet. | ||
- Click "Create a Subgraph". It is recommended to name the subgraph in Title Case: "Subgraph Name Chain Name". | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
> Note: After publishing, the subgraph name will be editable but requires signing each time, so name it properly. | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
For additional information on subgraph creation and the Graph CLI, check out the subgraph [Quick Start](/quick-start/) and [Creating a Subgraph](/developing/creating-a-subgraph). | ||
|
||
### Authenticate Your Subgraph | ||
|
||
In The Graph CLI, use the auth command seen in Subgraph Studio: | ||
|
||
```sh | ||
graph auth --studio <your-auth-code> | ||
``` | ||
|
||
## 2. Deploy Your Subgraph to Studio | ||
|
||
In The Graph CLI, run the following command: | ||
|
||
```sh | ||
graph deploy --studio <slug> --ipfs-hash <your-subgraph-ipfs-hash> | ||
idalithb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
> Note: There is no coding required, simply use the **IPFS provided by your current host**. You’ll be prompted to enter a version (e.g., v0.0.1). | ||
|
||
## 3. Publish Your Subgraph to The Graph Network | ||
|
||
 | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Query Your Subgraph | ||
|
||
> To attract about 3 indexers to query your subgraph, it’s recommended to curate at least 3,000 GRT. To learn more about curating, check out [Curating](/network/curating/) on The Graph. | ||
|
||
You can start querying any subgraph by sending a GraphQL query into the subgraph’s query URL endpoint, which is located at the top of its Explorer page in Subgraph Studio. | ||
|
||
#### Example | ||
|
||
[CryptoPunks Ethereum subgraph](https://thegraph.com/explorer/subgraphs/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK) by Messari: | ||
|
||
 | ||
|
||
|
||
The query URL for this subgraph is: | ||
|
||
```sh | ||
https://gateway-arbitrum.network.thegraph.com/api/`**your-own-api-key**`/subgraphs/id/HdVdERFUe8h61vm2fDyycgxjsde5PbB832NHgJfZNqK | ||
``` | ||
|
||
Now, you simply need to fill in **your own API Key** to start sending GraphQL queries to this endpoint. | ||
|
||
### Getting your own API Key | ||
|
||
You can create API Keys in Subgraph Studio under the “API Keys” menu at the top of the page: | ||
|
||
 | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Sample Query | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
This query shows the most expensive CryptoPunks sold. | ||
|
||
```graphql | ||
{ | ||
trades(orderBy: priceETH, orderDirection: desc) { | ||
priceETH | ||
tokenId | ||
} | ||
} | ||
``` | ||
|
||
Passing this into the query URL returns this result: | ||
|
||
```graphql | ||
{ | ||
"data": { | ||
"trades": [ | ||
{ | ||
"priceETH": "124457.067524886018255505", | ||
"tokenId": "9998" | ||
}, | ||
{ | ||
"priceETH": "8000", | ||
"tokenId": "5822" | ||
} | ||
// ... | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<aside /> | ||
|
||
### Sample code | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```jsx | ||
const axios = require('axios') | ||
|
||
const graphqlQuery = `{ | ||
trades(orderBy: priceETH, orderDirection: desc) { | ||
priceETH | ||
tokenId | ||
} | ||
}`; | ||
const queryUrl = | ||
'https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK' | ||
|
||
const graphQLRequest = { | ||
method: 'post', | ||
url: queryUrl, | ||
data: { | ||
query: graphqlQuery, | ||
}, | ||
}; | ||
|
||
// Send the GraphQL query | ||
axios(graphQLRequest) | ||
.then((response) => { | ||
// Handle the response here | ||
const data = response.data.data; | ||
console.log(data); | ||
}) | ||
.catch(error) => { | ||
// Handle any errors | ||
console.error(error); | ||
}); | ||
``` | ||
|
||
### Monitor Subgraph Status | ||
|
||
Once you upgrade, you can access and manage your subgraphs in [Subgraph Studio](https://thegraph.com/studio/) and explore all subgraphs in [The Graph Explorer](https://thegraph.com/networks/). | ||
|
||
### Additional Resources | ||
|
||
- To explore all the ways you can optimize & customize your subgraph for a better performance, read more about [creating a subgraph here](https://thegraph.com/docs/en/developing/creating-a-subgraph/). | ||
- For more information about querying data from your subgraph, read more [here](https://thegraph.com/docs/en/querying/querying-the-graph/). | ||
idalithb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.