mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
Removing Pool example queries and adding new examples (#493)
This commit is contained in:
parent
1289a085bb
commit
cedd082749
135
README.md
135
README.md
@ -37,51 +37,15 @@ This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
|
|||||||
|
|
||||||
## ⛵ Example Queries
|
## ⛵ Example Queries
|
||||||
|
|
||||||
**All pools**
|
|
||||||
|
|
||||||
```graphql
|
|
||||||
{
|
|
||||||
pools(orderBy: baseTokenLiquidity, orderDirection: desc) {
|
|
||||||
id
|
|
||||||
datatoken {
|
|
||||||
address
|
|
||||||
}
|
|
||||||
baseToken {
|
|
||||||
symbol
|
|
||||||
}
|
|
||||||
baseTokenLiquidity
|
|
||||||
datatokenLiquidity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Pools with the highest liquidity**
|
|
||||||
|
|
||||||
```graphql
|
|
||||||
{
|
|
||||||
pools(where: {datatokenLiquidity_gte: 1}, orderBy: baseTokenLiquidity, orderDirection: desc, first: 15) {
|
|
||||||
id
|
|
||||||
datatoken {
|
|
||||||
address
|
|
||||||
}
|
|
||||||
baseToken {
|
|
||||||
symbol
|
|
||||||
}
|
|
||||||
baseTokenLiquidity
|
|
||||||
datatokenLiquidity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**All Data NFTs**
|
**All Data NFTs**
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
{
|
{
|
||||||
nfts(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
|
nfts(orderBy: createdTimestamp, orderDirection: desc, first: 1000) {
|
||||||
id,
|
id
|
||||||
symbol,
|
symbol
|
||||||
name,
|
name
|
||||||
creator,
|
creator
|
||||||
createdTimestamp
|
createdTimestamp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,93 +53,66 @@ This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
|
|||||||
|
|
||||||
> Note: 1000 is the maximum number of items the subgraph can return.
|
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||||
|
|
||||||
**All Datatokens**
|
**Total Orders for Each User**
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
{
|
{
|
||||||
tokens(where: {isDatatoken: true}, orderBy: createdTimestamp, orderDirection: desc, first: 1000) {
|
users(first: 1000) {
|
||||||
id
|
id
|
||||||
symbol
|
totalOrders
|
||||||
name
|
|
||||||
address
|
|
||||||
holderCount
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**All pool transactions for a given user**
|
**Total Orders for All Users**
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
{
|
{
|
||||||
poolTransactions(
|
users(first: 1000) {
|
||||||
orderBy: timestamp
|
|
||||||
orderDirection: desc
|
|
||||||
where: { user: $user }
|
|
||||||
first: 1000
|
|
||||||
) {
|
|
||||||
baseToken {
|
|
||||||
symbol
|
|
||||||
address
|
|
||||||
}
|
|
||||||
baseTokenValue
|
|
||||||
datatoken {
|
|
||||||
symbol
|
|
||||||
address
|
|
||||||
}
|
|
||||||
datatokenValue
|
|
||||||
type
|
|
||||||
tx
|
|
||||||
timestamp
|
|
||||||
pool {
|
|
||||||
datatoken {
|
|
||||||
id
|
id
|
||||||
|
totalOrders
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||||
|
|
||||||
|
**Total Orders for a Specific User**
|
||||||
|
|
||||||
|
```graphql
|
||||||
|
{
|
||||||
|
user(id: $user) {
|
||||||
id
|
id
|
||||||
|
totalOrders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: all ETH addresses like `$user` in above example need to be passed as a lowercase string.
|
> Note: all ETH addresses like `$user` in above example need to be passed as a lowercase string.
|
||||||
|
|
||||||
**All pool transactions for a given user in an individual pool**
|
**All Orders**
|
||||||
|
|
||||||
```graphql
|
```
|
||||||
{
|
{
|
||||||
poolTransactions(
|
orders(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
|
||||||
orderBy: timestamp
|
amount
|
||||||
orderDirection: desc
|
|
||||||
where: { pool: $pool, user: $user }
|
|
||||||
first: 1000
|
|
||||||
) {
|
|
||||||
baseToken {
|
|
||||||
symbol
|
|
||||||
address
|
|
||||||
}
|
|
||||||
baseTokenValue
|
|
||||||
datatoken {
|
|
||||||
symbol
|
|
||||||
address
|
|
||||||
}
|
|
||||||
datatokenValue
|
|
||||||
type
|
|
||||||
tx
|
|
||||||
timestamp
|
|
||||||
pool {
|
|
||||||
datatoken {
|
datatoken {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
consumer {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
payer {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: all ETH addresses like `$pool` and `$user` in above example need to be passed as a lowercase string.
|
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||||
|
|
||||||
## 🏊 Development on Barge
|
## 🏊 Development on Barge
|
||||||
|
|
||||||
|
|
||||||
1. Clone [barge](https://github.com/oceanprotocol/barge) and run it in another terminal:
|
1. Clone [barge](https://github.com/oceanprotocol/barge) and run it in another terminal:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -195,11 +132,13 @@ npm i
|
|||||||
```
|
```
|
||||||
|
|
||||||
3. Let the components know where to pickup the smart contract addresses.
|
3. Let the components know where to pickup the smart contract addresses.
|
||||||
|
|
||||||
```
|
```
|
||||||
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Generate the subgraphs
|
4. Generate the subgraphs
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
node ./scripts/generatenetworkssubgraphs.js barge
|
node ./scripts/generatenetworkssubgraphs.js barge
|
||||||
npm run codegen
|
npm run codegen
|
||||||
@ -219,10 +158,8 @@ npm run deploy:local
|
|||||||
|
|
||||||
You now have a local graph-node running on http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
|
You now have a local graph-node running on http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
|
||||||
|
|
||||||
|
|
||||||
## 🏊 Deploying graphs for live networks
|
## 🏊 Deploying graphs for live networks
|
||||||
|
|
||||||
|
|
||||||
1. Clone the repo and install dependencies:
|
1. Clone the repo and install dependencies:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -232,11 +169,11 @@ npm i
|
|||||||
```
|
```
|
||||||
|
|
||||||
2. Generate & deploy on rinkeby
|
2. Generate & deploy on rinkeby
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run quickstart:rinkeby
|
npm run quickstart:rinkeby
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 🔍 Testing
|
## 🔍 Testing
|
||||||
|
|
||||||
- Please note: the `npm run test` command is currently not working due to [this issue](https://github.com/graphprotocol/graph-ts/issues/113).
|
- Please note: the `npm run test` command is currently not working due to [this issue](https://github.com/graphprotocol/graph-ts/issues/113).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user