Add a CLI to compare entity query results from two GQL endpoints (#57)

* Add CLI to compare entities from two GQL endpoints

* Print out result diffs in compare-entity CLI

* Get the colorized result diff in compare-entity CLI

* Read query dir from config file or as an arg

* Make config file arg required

* Make queries in Example schema similar to that in graph-node

* Get non-colorized output on choosing raw-json diff option

* Make queries in eden-watcher similar to that in graph-node
This commit is contained in:
prathamesh0
2021-12-28 16:08:05 +05:30
committed by nabarun
parent 31b302c9b5
commit d979e51723
35 changed files with 535 additions and 413 deletions
+42
View File
@@ -36,3 +36,45 @@
6. Run `yarn build:example` to build the wasm files.
7. Run `yarn test`.
## Run
* Compare query results from two different GQL endpoints:
* In a config file (sample: `environments/compare-cli-config.toml`):
* Specify the two GQL endpoints in the endpoints config.
* Specify the query directory in queries config or pass as an arg. to the CLI.
* Example:
```
[endpoints]
gqlEndpoint1 = "http://localhost:8000/subgraphs/name/example1"
gqlEndpoint2 = "http://localhost:3008/graphql"
[queries]
queryDir = "../graph-test-watcher/src/gql/queries"
```
* Fire a query and get the diff of the results from the two GQL endpoints:
```bash
yarn compare-entity --config-file <config-file-path> --query-dir [query-dir] --query-name <query-name> --block-hash <block-hash> --entity-id <entity-id> --raw-json [true | false]
```
* `config-file`(alias: `cf`): Configuration file path (toml) (required).
* `query-dir`(alias: `qf`): Path to queries directory (defualt: taken from the config file).
* `query-name`(alias: `q`): Query to be fired (required).
* `block-hash`(alias: `b`): Block hash (required).
* `entity-id`(alias: `i`): Entity Id (required).
* `raw-json`(alias: `j`): Whether to print out a raw diff object (default: `false`).
Example:
```bash
yarn compare-entity --config-file environments/compare-cli-config.toml --query-name exampleEntity --block-hash 0xceed7ee9d3de97c99db12e42433cae9115bb311c516558539fb7114fa17d545b --entity-id 0x2886bae64814bd959aec4282f86f3a97bf1e16e4111b39fd7bdd592b516c66c6
```
* The program will exit with code `1` if the query results are not equal.