mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-28 02:52:08 +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.
|
// Add type and query for SyncStatus.
|
||||||
this._addSyncStatus();
|
this._addSyncStatus();
|
||||||
|
|
||||||
// Add type and query for meta data
|
|
||||||
this._addMeta();
|
|
||||||
|
|
||||||
// Build the schema.
|
// Build the schema.
|
||||||
return this._composer.buildSchema();
|
return this._composer.buildSchema();
|
||||||
}
|
}
|
||||||
@ -186,6 +183,9 @@ export class Schema {
|
|||||||
|
|
||||||
// Add subgraph-schema entity queries to the schema composer.
|
// Add subgraph-schema entity queries to the schema composer.
|
||||||
this._addSubgraphSchemaQueries(subgraphTypeDefs);
|
this._addSubgraphSchemaQueries(subgraphTypeDefs);
|
||||||
|
|
||||||
|
// Add type and query for meta data
|
||||||
|
this._addMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
_addSubgraphSchemaQueries (subgraphTypeDefs: ReadonlyArray<DefinitionNode>): void {
|
_addSubgraphSchemaQueries (subgraphTypeDefs: ReadonlyArray<DefinitionNode>): void {
|
||||||
|
@ -71,9 +71,9 @@
|
|||||||
isFEVM = false
|
isFEVM = false
|
||||||
|
|
||||||
# Boolean flag to filter event logs by contracts
|
# Boolean flag to filter event logs by contracts
|
||||||
filterLogsByAddresses = false
|
filterLogsByAddresses = true
|
||||||
# Boolean flag to filter event logs by topics
|
# Boolean flag to filter event logs by topics
|
||||||
filterLogsByTopics = false
|
filterLogsByTopics = true
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
@ -32,6 +32,7 @@ import {
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
BlockHeight,
|
BlockHeight,
|
||||||
|
ResultMeta,
|
||||||
updateSubgraphState,
|
updateSubgraphState,
|
||||||
dumpSubgraphState,
|
dumpSubgraphState,
|
||||||
GraphWatcherInterface,
|
GraphWatcherInterface,
|
||||||
@ -44,7 +45,6 @@ import {
|
|||||||
Clients,
|
Clients,
|
||||||
EthClient,
|
EthClient,
|
||||||
UpstreamConfig,
|
UpstreamConfig,
|
||||||
ResultMeta,
|
|
||||||
EthFullBlock,
|
EthFullBlock,
|
||||||
EthFullTransaction,
|
EthFullTransaction,
|
||||||
ExtraEventData
|
ExtraEventData
|
||||||
@ -153,9 +153,11 @@ export class Indexer implements IndexerInterface {
|
|||||||
assert({{contract.contractName}}ABI);
|
assert({{contract.contractName}}ABI);
|
||||||
this._abiMap.set(KIND_{{capitalize contract.contractName}}, {{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);
|
contractInterface = new ethers.utils.Interface({{contract.contractName}}ABI);
|
||||||
this._contractMap.set(KIND_{{capitalize contract.contractName}}, contractInterface);
|
this._contractMap.set(KIND_{{capitalize contract.contractName}}, contractInterface);
|
||||||
|
|
||||||
|
// eslint-disable-next-line prefer-const
|
||||||
eventSignatures = Object.values(contractInterface.events).map(value => {
|
eventSignatures = Object.values(contractInterface.events).map(value => {
|
||||||
return contractInterface.getEventTopic(value);
|
return contractInterface.getEventTopic(value);
|
||||||
});
|
});
|
||||||
@ -201,10 +203,12 @@ export class Indexer implements IndexerInterface {
|
|||||||
await this._baseIndexer.fetchStateStatus();
|
await this._baseIndexer.fetchStateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
async getMetaData (block: BlockHeight): Promise<ResultMeta | null> {
|
async getMetaData (block: BlockHeight): Promise<ResultMeta | null> {
|
||||||
return this._baseIndexer.getMetaData(block);
|
return this._baseIndexer.getMetaData(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
getResultEvent (event: Event): ResultEvent {
|
getResultEvent (event: Event): ResultEvent {
|
||||||
return getResultEvent(event);
|
return getResultEvent(event);
|
||||||
}
|
}
|
||||||
@ -467,6 +471,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
async triggerIndexingOnEvent (event: Event, extraData: ExtraEventData): Promise<void> {
|
async triggerIndexingOnEvent (event: Event, extraData: ExtraEventData): Promise<void> {
|
||||||
const resultEvent = this.getResultEvent(event);
|
const resultEvent = this.getResultEvent(event);
|
||||||
|
|
||||||
|
@ -185,14 +185,7 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
|||||||
|
|
||||||
return state && state.block.isComplete ? getResultState(state) : undefined;
|
return state && state.block.isComplete ? getResultState(state) : undefined;
|
||||||
},
|
},
|
||||||
|
{{#if (subgraphPath)}}
|
||||||
getSyncStatus: async () => {
|
|
||||||
log('getSyncStatus');
|
|
||||||
gqlTotalQueryCount.inc(1);
|
|
||||||
gqlQueryCount.labels('getSyncStatus').inc(1);
|
|
||||||
|
|
||||||
return indexer.getSyncStatus();
|
|
||||||
},
|
|
||||||
|
|
||||||
_meta: async (
|
_meta: async (
|
||||||
_: any,
|
_: any,
|
||||||
@ -203,6 +196,15 @@ export const createResolvers = async (indexerArg: IndexerInterface, eventWatcher
|
|||||||
gqlQueryCount.labels('_meta').inc(1);
|
gqlQueryCount.labels('_meta').inc(1);
|
||||||
|
|
||||||
return indexer.getMetaData(block);
|
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';
|
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';
|
const GRAPH_CLI_VERSION = '0.32.0-watcher-ts-0.1.3';
|
||||||
|
|
||||||
export function parseSubgraphSchema (subgraphPath: string, subgraphConfig: any): any {
|
export function parseSubgraphSchema (subgraphPath: string, subgraphConfig: any): any {
|
||||||
|
Loading…
Reference in New Issue
Block a user