1.0.7 • Published 11 months ago

linear-graph-results-pager v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

linear-graph-results-pager

Utility to get paged results from The Graph endpoints

Node & Webpack Usage

const graphResultsPager = require('linear-graph-results-pager'); // common js
// or
import graphResultsPager from 'linear-graph-results-pager';

graphResultsPager({
	api: 'https://api.thegraph.com/subgraphs/name/...',
	headers: {},
	// 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/linear-graph-results-pager/browser.js"></script>
<script>
	window.graphResultsPager({...}).then(console.log).catch(console.error)
</script>
1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago