Socket
Book a DemoInstallSign in
Socket

graph-results-pager

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph-results-pager

Utility to get paged results from The Graph subgraphs

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

graph-results-pager

npm version

Utility to get paged results from The Graph endpoints

Node & Webpack Usage

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)

Direct browser usage

<script src="//cdn.jsdelivr.net/npm/graph-results-pager/browser.js"></script>
<script>
	window.graphResultsPager({...}).then(console.log).catch(console.error)
</script>

Keywords

thegraprotocol

FAQs

Package last updated on 23 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts