mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 20:36:19 +00:00
Skip meta query generation for non-subgraph watchers (#481)
* Skip generating meta query if non subgraph watcher * Fix linting errors in generated watcher * Add space for meta query * Add meta query types after adding block height type --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
parent
7b19d383ec
commit
d0aca37a74
@ -106,9 +106,6 @@ export class Schema {
|
||||
// Add type and query for SyncStatus.
|
||||
this._addSyncStatus();
|
||||
|
||||
// Add type and query for meta data
|
||||
this._addMeta();
|
||||
|
||||
// Build the schema.
|
||||
return this._composer.buildSchema();
|
||||
}
|
||||
@ -186,6 +183,9 @@ export class Schema {
|
||||
|
||||
// Add subgraph-schema entity queries to the schema composer.
|
||||
this._addSubgraphSchemaQueries(subgraphTypeDefs);
|
||||
|
||||
// Add type and query for meta data
|
||||
this._addMeta();
|
||||
}
|
||||
|
||||
_addSubgraphSchemaQueries (subgraphTypeDefs: ReadonlyArray<DefinitionNode>): void {
|
||||
|
@ -71,9 +71,9 @@
|
||||
isFEVM = false
|
||||
|
||||
# Boolean flag to filter event logs by contracts
|
||||
filterLogsByAddresses = false
|
||||
filterLogsByAddresses = true
|
||||
# Boolean flag to filter event logs by topics
|
||||
filterLogsByTopics = false
|
||||
filterLogsByTopics = true
|
||||
|
||||
[upstream.cache]
|
||||
name = "requests"
|
||||
|
@ -32,6 +32,7 @@ import {
|
||||
{{/if}}
|
||||
{{#if (subgraphPath)}}
|
||||
BlockHeight,
|
||||
ResultMeta,
|
||||
updateSubgraphState,
|
||||
dumpSubgraphState,
|
||||
GraphWatcherInterface,
|
||||
@ -44,7 +45,6 @@ import {
|
||||
Clients,
|
||||
EthClient,
|
||||
UpstreamConfig,
|
||||
ResultMeta,
|
||||
EthFullBlock,
|
||||
EthFullTransaction,
|
||||
ExtraEventData
|
||||
@ -153,9 +153,11 @@ export class Indexer implements IndexerInterface {
|
||||
assert({{contract.contractName}}ABI);
|
||||
this._abiMap.set(KIND_{{capitalize contract.contractName}}, {{contract.contractName}}ABI);
|
||||
|
||||
// eslint-disable-next-line prefer-const
|
||||
contractInterface = new ethers.utils.Interface({{contract.contractName}}ABI);
|
||||
this._contractMap.set(KIND_{{capitalize contract.contractName}}, contractInterface);
|
||||
|
||||
// eslint-disable-next-line prefer-const
|
||||
eventSignatures = Object.values(contractInterface.events).map(value => {
|
||||
return contractInterface.getEventTopic(value);
|
||||
});
|
||||
@ -201,10 +203,12 @@ export class Indexer implements IndexerInterface {
|
||||
await this._baseIndexer.fetchStateStatus();
|
||||
}
|
||||
|
||||
{{#if (subgraphPath)}}
|
||||
async getMetaData (block: BlockHeight): Promise<ResultMeta | null> {
|
||||
return this._baseIndexer.getMetaData(block);
|
||||
}
|
||||
|
||||
{{/if}}
|
||||
getResultEvent (event: Event): ResultEvent {
|
||||
return getResultEvent(event);
|
||||
}
|
||||
@ -467,6 +471,7 @@ export class Indexer implements IndexerInterface {
|
||||
}
|
||||
|
||||
{{/if}}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async triggerIndexingOnEvent (event: Event, extraData: ExtraEventData): Promise<void> {
|
||||
const resultEvent = this.getResultEvent(event);
|
||||
|
||||
|
@ -185,14 +185,7 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
||||
|
||||
return state && state.block.isComplete ? getResultState(state) : undefined;
|
||||
},
|
||||
|
||||
getSyncStatus: async () => {
|
||||
log('getSyncStatus');
|
||||
gqlTotalQueryCount.inc(1);
|
||||
gqlQueryCount.labels('getSyncStatus').inc(1);
|
||||
|
||||
return indexer.getSyncStatus();
|
||||
},
|
||||
{{#if (subgraphPath)}}
|
||||
|
||||
_meta: async (
|
||||
_: any,
|
||||
@ -203,6 +196,15 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
||||
gqlQueryCount.labels('_meta').inc(1);
|
||||
|
||||
return indexer.getMetaData(block);
|
||||
},
|
||||
{{/if}}
|
||||
|
||||
getSyncStatus: async () => {
|
||||
log('getSyncStatus');
|
||||
gqlTotalQueryCount.inc(1);
|
||||
gqlQueryCount.labels('getSyncStatus').inc(1);
|
||||
|
||||
return indexer.getSyncStatus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ import { loadFilesSync } from '@graphql-tools/load-files';
|
||||
|
||||
import { ASSET_DIR } from './constants';
|
||||
|
||||
const GRAPH_TS_VERSION = '0.27.0-watcher-ts-0.1.2';
|
||||
const GRAPH_TS_VERSION = '0.27.0-watcher-ts-0.1.3';
|
||||
const GRAPH_CLI_VERSION = '0.32.0-watcher-ts-0.1.3';
|
||||
|
||||
export function parseSubgraphSchema (subgraphPath: string, subgraphConfig: any): any {
|
||||
|
Loading…
Reference in New Issue
Block a user