Removing Pool example queries and adding new examples (#493)

This commit is contained in:
Jamie Hewitt 2022-08-01 14:59:22 +03:00 committed by GitHub
parent 1289a085bb
commit cedd082749
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 48 additions and 111 deletions

129
README.md
View File

@ -37,51 +37,15 @@ This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
## ⛵ 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**
```graphql
{
nfts(orderBy: createdTimestamp, orderDirection: desc, first: 1000) {
id,
symbol,
name,
creator,
id
symbol
name
creator
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.
**All Datatokens**
**Total Orders for Each User**
```graphql
{
tokens(where: {isDatatoken: true}, orderBy: createdTimestamp, orderDirection: desc, first: 1000) {
users(first: 1000) {
id
symbol
name
address
holderCount
totalOrders
}
}
```
**All pool transactions for a given user**
**Total Orders for All Users**
```graphql
{
poolTransactions(
orderBy: timestamp
orderDirection: desc
where: { user: $user }
first: 1000
) {
baseToken {
symbol
address
}
baseTokenValue
datatoken {
symbol
address
}
datatokenValue
type
tx
timestamp
pool {
datatoken {
users(first: 1000) {
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
}
totalOrders
}
}
```
> 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(
orderBy: timestamp
orderDirection: desc
where: { pool: $pool, user: $user }
first: 1000
) {
baseToken {
symbol
address
}
baseTokenValue
datatoken {
symbol
address
}
datatokenValue
type
tx
timestamp
pool {
orders(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
amount
datatoken {
id
}
consumer {
id
}
payer {
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
1. Clone [barge](https://github.com/oceanprotocol/barge) and run it in another terminal:
```bash
@ -195,11 +132,13 @@ npm i
```
3. Let the components know where to pickup the smart contract addresses.
```
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
```
4. Generate the subgraphs
```bash
node ./scripts/generatenetworkssubgraphs.js barge
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
## 🏊 Deploying graphs for live networks
1. Clone the repo and install dependencies:
```bash
@ -232,11 +169,11 @@ npm i
```
2. Generate & deploy on rinkeby
```bash
npm run quickstart:rinkeby
```
## 🔍 Testing
- Please note: the `npm run test` command is currently not working due to [this issue](https://github.com/graphprotocol/graph-ts/issues/113).