mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
Support fragments in GQL queries for subgraph watchers (#510)
* Avoid updating latest block metrics on RPC errors * Handle fragments in subgraph GQL queries * Upgrade package versions * Move private method in util graph database --------- Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cerc-io/codegen",
|
||||
"version": "0.2.88",
|
||||
"version": "0.2.89",
|
||||
"description": "Code generator",
|
||||
"private": true,
|
||||
"main": "index.js",
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
|
||||
"dependencies": {
|
||||
"@cerc-io/util": "^0.2.88",
|
||||
"@cerc-io/util": "^0.2.89",
|
||||
"@graphql-tools/load-files": "^6.5.2",
|
||||
"@npmcli/package-json": "^5.0.0",
|
||||
"@poanet/solidity-flattener": "https://github.com/vulcanize/solidity-flattener.git",
|
||||
|
||||
@@ -10,7 +10,7 @@ import JSONbig from 'json-bigint';
|
||||
{{/if}}
|
||||
import { ethers, constants } from 'ethers';
|
||||
{{#if (subgraphPath)}}
|
||||
import { SelectionNode } from 'graphql';
|
||||
import { GraphQLResolveInfo } from 'graphql';
|
||||
{{/if}}
|
||||
|
||||
import { JsonFragment } from '@ethersproject/abi';
|
||||
@@ -458,9 +458,9 @@ export class Indexer implements IndexerInterface {
|
||||
entity: new () => Entity,
|
||||
id: string,
|
||||
block: BlockHeight,
|
||||
selections: ReadonlyArray<SelectionNode> = []
|
||||
queryInfo: GraphQLResolveInfo
|
||||
): Promise<any> {
|
||||
const data = await this._graphWatcher.getEntity(entity, id, this._relationsMap, block, selections);
|
||||
const data = await this._graphWatcher.getEntity(entity, id, this._relationsMap, block, queryInfo);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -470,9 +470,9 @@ export class Indexer implements IndexerInterface {
|
||||
block: BlockHeight,
|
||||
where: { [key: string]: any } = {},
|
||||
queryOptions: QueryOptions = {},
|
||||
selections: ReadonlyArray<SelectionNode> = []
|
||||
queryInfo: GraphQLResolveInfo
|
||||
): Promise<any[]> {
|
||||
return this._graphWatcher.getEntities(entity, this._relationsMap, block, where, queryOptions, selections);
|
||||
return this._graphWatcher.getEntities(entity, this._relationsMap, block, where, queryOptions, queryInfo);
|
||||
}
|
||||
|
||||
{{/if}}
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
|
||||
"dependencies": {
|
||||
"@apollo/client": "^3.3.19",
|
||||
"@cerc-io/cli": "^0.2.88",
|
||||
"@cerc-io/ipld-eth-client": "^0.2.88",
|
||||
"@cerc-io/solidity-mapper": "^0.2.88",
|
||||
"@cerc-io/util": "^0.2.88",
|
||||
"@cerc-io/cli": "^0.2.89",
|
||||
"@cerc-io/ipld-eth-client": "^0.2.89",
|
||||
"@cerc-io/solidity-mapper": "^0.2.89",
|
||||
"@cerc-io/util": "^0.2.89",
|
||||
{{#if (subgraphPath)}}
|
||||
"@cerc-io/graph-node": "^0.2.88",
|
||||
"@cerc-io/graph-node": "^0.2.89",
|
||||
{{/if}}
|
||||
"@ethersproject/providers": "^5.4.4",
|
||||
"debug": "^4.3.1",
|
||||
|
||||
@@ -106,12 +106,11 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
||||
log('{{this.queryName}}', id, JSON.stringify(block, jsonBigIntStringReplacer));
|
||||
gqlTotalQueryCount.inc(1);
|
||||
gqlQueryCount.labels('{{this.queryName}}').inc(1);
|
||||
assert(info.fieldNodes[0].selectionSet);
|
||||
|
||||
// Set cache-control hints
|
||||
// setGQLCacheHints(info, block, gqlCacheConfig);
|
||||
|
||||
return indexer.getSubgraphEntity({{this.entityName}}, id, block, info.fieldNodes[0].selectionSet.selections);
|
||||
return indexer.getSubgraphEntity({{this.entityName}}, id, block, info);
|
||||
},
|
||||
|
||||
{{this.pluralQueryName}}: async (
|
||||
@@ -123,7 +122,6 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
||||
log('{{this.pluralQueryName}}', JSON.stringify(block, jsonBigIntStringReplacer), JSON.stringify(where, jsonBigIntStringReplacer), first, skip, orderBy, orderDirection);
|
||||
gqlTotalQueryCount.inc(1);
|
||||
gqlQueryCount.labels('{{this.pluralQueryName}}').inc(1);
|
||||
assert(info.fieldNodes[0].selectionSet);
|
||||
|
||||
// Set cache-control hints
|
||||
// setGQLCacheHints(info, block, gqlCacheConfig);
|
||||
@@ -133,7 +131,7 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
||||
block,
|
||||
where,
|
||||
{ limit: first, skip, orderBy, orderDirection },
|
||||
info.fieldNodes[0].selectionSet.selections
|
||||
info
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user