https://github.com/justinjmoses/graph-results-pager
Utility to get paged results from The Graph endpoints
https://github.com/justinjmoses/graph-results-pager
dapps ethereum thegraphprotocol
Last synced: about 1 year ago
JSON representation
Utility to get paged results from The Graph endpoints
- Host: GitHub
- URL: https://github.com/justinjmoses/graph-results-pager
- Owner: jjgonecrypto
- License: mit
- Created: 2020-01-30T04:44:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T10:09:10.000Z (almost 2 years ago)
- Last Synced: 2025-04-09T19:05:12.196Z (about 1 year ago)
- Topics: dapps, ethereum, thegraphprotocol
- Language: JavaScript
- Size: 372 KB
- Stars: 13
- Watchers: 4
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graph-results-pager
[](https://badge.fury.io/js/graph-results-pager)
Utility to get paged results from The Graph endpoints
## Node & Webpack Usage
```javascript
const graphResultsPager = require('graph-results-pager'); // common js
// or
import graphResultsPager from 'graph-results-pager';
graphResultsPager({
api: 'https://api.thegraph.com/subgraphs/name/...',
// Note: a single subgraph fetch can return 1000 results, any larger numbers will trigger multiple fetches
max: 12, // leave empty for all results
timeout: 5e3, // 5s timeout for an individual page request
query: {
entity: '...',
selection: {
orderBy: '...',
orderDirection: 'desc',
where: {
// Note: the below filters are combined - like the AND operater in an SQL WHERE clause
someStringField: `\\"${someValue}\\"`, // use double quotes for strings / bytes / addresses
someNumber: 321, // numbers don't require escaping
// ...
willBeIgnored: undefined, // useful if you want to use the ternary operator for inline checks
},
},
properties: [
'id',
...ss, // the list of the entity's fields you want returned
],
},
});
```
For an example in node, try running `node example.js` ([see source](./example.js))
## Direct browser usage
```html
window.graphResultsPager({...}).then(console.log).catch(console.error)
```