Add config for query limit in compare CLI (#175)

* Add config for query limit in compare CLI

* Fix JSON stringify bigint for GQL query params

* Take last N entity ids to compare in GQL
This commit is contained in:
2022-09-08 16:54:02 +05:30
committed by GitHub
parent 93584bf28d
commit 4e5ec36f07
6 changed files with 41 additions and 31 deletions
@@ -3,13 +3,14 @@
gqlEndpoint2 = "http://localhost:3008/graphql"
[queries]
queryDir = "../graph-test-watcher/src/gql/queries"
queryDir = "../../graph-test-watcher/src/gql/queries"
names = []
blockDelayInMs = 250
queryLimits = {}
[watcher]
configPath = "../../graph-test-watcher/environments/local.toml"
entitiesDir = "../../graph-test-watcher/src/entity"
entitiesDir = "../../graph-test-watcher/dist/entity/*"
endpoint = "gqlEndpoint2"
verifyState = true
derivedFields = []
@@ -120,6 +120,14 @@ export const main = async (): Promise<void> => {
let resultDiff = '';
if (fetchIds) {
const queryLimit = config.queries.queryLimits[queryName];
if (queryLimit) {
// Take only last `queryLimit` entity ids to compare in GQL.
const idsLength = updatedEntityIds[index].length;
updatedEntityIds[index].splice(0, idsLength - queryLimit);
}
for (const id of updatedEntityIds[index]) {
const { diff, result1: result } = await compareQuery(
clients,
@@ -36,6 +36,7 @@ interface QueryConfig {
queryDir: string;
names: string[];
blockDelayInMs: number;
queryLimits: { [queryName: string]: number }
}
interface EntityDerivedFields {