mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-06 19:47:59 +00:00
Fixes after comparing with existing eden watcher (#94)
This commit is contained in:
parent
feac6bad16
commit
e5faba8e68
@ -79,6 +79,7 @@ export class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_exportGql (schemaContent: string, gqlDir: string): void {
|
_exportGql (schemaContent: string, gqlDir: string): void {
|
||||||
gqlGenerate(schemaContent, gqlDir);
|
// TODO: Implement nested queries for subgraph entities.
|
||||||
|
gqlGenerate(schemaContent, gqlDir, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,22 +427,6 @@ export class Entity {
|
|||||||
const { typeName, array, nullable } = getFieldType(field.type);
|
const { typeName, array, nullable } = getFieldType(field.type);
|
||||||
let tsType = getTsForGql(typeName);
|
let tsType = getTsForGql(typeName);
|
||||||
|
|
||||||
if (!tsType) {
|
|
||||||
tsType = 'string';
|
|
||||||
}
|
|
||||||
|
|
||||||
columnObject.tsType = tsType;
|
|
||||||
|
|
||||||
// Handle basic array types.
|
|
||||||
if (array) {
|
|
||||||
columnObject.columnOptions.push({
|
|
||||||
option: 'array',
|
|
||||||
value: 'true'
|
|
||||||
});
|
|
||||||
|
|
||||||
columnObject.tsType = `${tsType}[]`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subgraphTypeDefs.some((typeDef: any) => typeDef.kind === 'EnumTypeDefinition' && typeDef.name.value === typeName)) {
|
if (subgraphTypeDefs.some((typeDef: any) => typeDef.kind === 'EnumTypeDefinition' && typeDef.name.value === typeName)) {
|
||||||
// Create enum type column.
|
// Create enum type column.
|
||||||
|
|
||||||
@ -469,11 +453,29 @@ export class Entity {
|
|||||||
value: typeName
|
value: typeName
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
columnObject.tsType = typeName;
|
||||||
} else {
|
} else {
|
||||||
|
if (!tsType) {
|
||||||
|
tsType = 'string';
|
||||||
|
}
|
||||||
|
|
||||||
|
columnObject.tsType = tsType;
|
||||||
|
|
||||||
// Enum type does not require pgType.
|
// Enum type does not require pgType.
|
||||||
columnObject.pgType = getPgForTs(tsType);
|
columnObject.pgType = getPgForTs(tsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle basic array types.
|
||||||
|
if (array) {
|
||||||
|
columnObject.columnOptions.push({
|
||||||
|
option: 'array',
|
||||||
|
value: 'true'
|
||||||
|
});
|
||||||
|
|
||||||
|
columnObject.tsType = `${tsType}[]`;
|
||||||
|
}
|
||||||
|
|
||||||
if (nullable) {
|
if (nullable) {
|
||||||
columnObject.columnOptions.push({
|
columnObject.columnOptions.push({
|
||||||
option: 'nullable',
|
option: 'nullable',
|
||||||
|
@ -85,6 +85,11 @@ export class Schema {
|
|||||||
acc[curr.name] = `${getGqlForTs(tsCurrType)}!`;
|
acc[curr.name] = `${getGqlForTs(tsCurrType)}!`;
|
||||||
return acc;
|
return acc;
|
||||||
}, typeObject.fields);
|
}, typeObject.fields);
|
||||||
|
} else {
|
||||||
|
// Types must define one or more fields.
|
||||||
|
typeObject.fields = {
|
||||||
|
dummy: 'String'
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a type composer to add the required type in the schema composer.
|
// Create a type composer to add the required type in the schema composer.
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
{{#if subgraphPath}}
|
{{#if subgraphPath}}
|
||||||
subgraphPath = "{{subgraphPath}}"
|
subgraphPath = "{{subgraphPath}}"
|
||||||
|
wasmRestartBlocksInterval = 20
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
|
@ -14,7 +14,6 @@ import { SyncStatus } from './entity/SyncStatus';
|
|||||||
import { HookStatus } from './entity/HookStatus';
|
import { HookStatus } from './entity/HookStatus';
|
||||||
import { BlockProgress } from './entity/BlockProgress';
|
import { BlockProgress } from './entity/BlockProgress';
|
||||||
import { IPLDBlock } from './entity/IPLDBlock';
|
import { IPLDBlock } from './entity/IPLDBlock';
|
||||||
|
|
||||||
{{#each queries as | query |}}
|
{{#each queries as | query |}}
|
||||||
import { {{query.entityName}} } from './entity/{{query.entityName}}';
|
import { {{query.entityName}} } from './entity/{{query.entityName}}';
|
||||||
{{/each}}
|
{{/each}}
|
||||||
@ -39,7 +38,9 @@ export class Database implements IPLDDatabaseInterface {
|
|||||||
|
|
||||||
async init (): Promise<void> {
|
async init (): Promise<void> {
|
||||||
this._conn = await this._baseDatabase.init();
|
this._conn = await this._baseDatabase.init();
|
||||||
|
{{#if queries}}
|
||||||
this._setPropColMaps();
|
this._setPropColMaps();
|
||||||
|
{{/if}}
|
||||||
}
|
}
|
||||||
|
|
||||||
async close (): Promise<void> {
|
async close (): Promise<void> {
|
||||||
@ -249,10 +250,12 @@ export class Database implements IPLDDatabaseInterface {
|
|||||||
return acc.set(curr.propertyName, curr.databaseName);
|
return acc.set(curr.propertyName, curr.databaseName);
|
||||||
}, new Map<string, string>());
|
}, new Map<string, string>());
|
||||||
}
|
}
|
||||||
|
{{#if queries}}
|
||||||
|
|
||||||
_setPropColMaps (): void {
|
_setPropColMaps (): void {
|
||||||
{{#each queries as | query |}}
|
{{#each queries as | query |}}
|
||||||
this._propColMaps.{{query.entityName}} = this._getPropertyColumnMapForEntity('{{query.entityName}}');
|
this._propColMaps.{{query.entityName}} = this._getPropertyColumnMapForEntity('{{query.entityName}}');
|
||||||
{{/each}}
|
{{/each}}
|
||||||
}
|
}
|
||||||
|
{{/if}}
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,6 @@ export const main = async (): Promise<any> => {
|
|||||||
|
|
||||||
const graphWatcher = new GraphWatcher(graphDb, postgraphileClient, ethProvider, config.server);
|
const graphWatcher = new GraphWatcher(graphDb, postgraphileClient, ethProvider, config.server);
|
||||||
|
|
||||||
// Note: In-memory pubsub works fine for now, as each watcher is a single process anyway.
|
|
||||||
// Later: https://www.apollographql.com/docs/apollo-server/data/subscriptions/#production-pubsub-libraries
|
|
||||||
const pubsub = new PubSub();
|
|
||||||
|
|
||||||
const jobQueueConfig = config.jobQueue;
|
const jobQueueConfig = config.jobQueue;
|
||||||
assert(jobQueueConfig, 'Missing job queue config');
|
assert(jobQueueConfig, 'Missing job queue config');
|
||||||
|
|
||||||
@ -82,6 +78,10 @@ export const main = async (): Promise<any> => {
|
|||||||
graphWatcher.setIndexer(indexer);
|
graphWatcher.setIndexer(indexer);
|
||||||
await graphWatcher.init();
|
await graphWatcher.init();
|
||||||
|
|
||||||
|
// Note: In-memory pubsub works fine for now, as each watcher is a single process anyway.
|
||||||
|
// Later: https://www.apollographql.com/docs/apollo-server/data/subscriptions/#production-pubsub-libraries
|
||||||
|
const pubsub = new PubSub();
|
||||||
|
|
||||||
const eventWatcher = new EventWatcher(config.upstream, ethClient, postgraphileClient, indexer, pubsub, jobQueue);
|
const eventWatcher = new EventWatcher(config.upstream, ethClient, postgraphileClient, indexer, pubsub, jobQueue);
|
||||||
|
|
||||||
await fillBlocks(jobQueue, indexer, eventWatcher, config.upstream.ethServer.blockDelayInMilliSecs, argv);
|
await fillBlocks(jobQueue, indexer, eventWatcher, config.upstream.ethServer.blockDelayInMilliSecs, argv);
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"@vulcanize/ipld-eth-client": "^0.1.0",
|
"@vulcanize/ipld-eth-client": "^0.1.0",
|
||||||
"@vulcanize/solidity-mapper": "^0.1.0",
|
"@vulcanize/solidity-mapper": "^0.1.0",
|
||||||
"@vulcanize/util": "^0.1.0",
|
"@vulcanize/util": "^0.1.0",
|
||||||
|
"@vulcanize/graph-node": "^0.1.0",
|
||||||
"apollo-server-express": "^2.25.0",
|
"apollo-server-express": "^2.25.0",
|
||||||
"apollo-type-bigint": "^0.1.3",
|
"apollo-type-bigint": "^0.1.3",
|
||||||
"debug": "^4.3.1",
|
"debug": "^4.3.1",
|
||||||
@ -48,7 +49,8 @@
|
|||||||
"multiformats": "^9.4.8",
|
"multiformats": "^9.4.8",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"typeorm": "^0.2.32",
|
"typeorm": "^0.2.32",
|
||||||
"yargs": "^17.0.1"
|
"yargs": "^17.0.1",
|
||||||
|
"decimal.js": "^10.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ethersproject/abi": "^5.3.0",
|
"@ethersproject/abi": "^5.3.0",
|
||||||
|
@ -83,7 +83,6 @@ const main = async (): Promise<void> => {
|
|||||||
|
|
||||||
await db.close();
|
await db.close();
|
||||||
await jobQueue.stop();
|
await jobQueue.stop();
|
||||||
process.exit();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
main().catch(err => {
|
main().catch(err => {
|
||||||
|
Loading…
Reference in New Issue
Block a user