@cerc-io/graph-node (0.2.107)

Published 2024-09-18 10:11:52 +00:00 by cerccicd in cerc-io/watcher-ts

Installation

@cerc-io:registry=
npm install @cerc-io/graph-node@0.2.107
"@cerc-io/graph-node": "0.2.107"

About this package

graph-node

Test

  1. Run yarn to install all dependencies.

  2. Create .env file

    $ cp .env.example .env
    
  3. Run yarn build:example to build the wasm files.

  4. 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:

      ./bin/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
      ./bin/compare-entity --config-file environments/compare-cli-config.toml --query-name author --block-hash 0xceed7ee9d3de97c99db12e42433cae9115bb311c516558539fb7114fa17d545b --entity-id 0xdc7d7a8920c8eecc098da5b7522a5f31509b5bfc
      ```
      
    • The program will exit with code 1 if the query results are not equal.

    • For comparing queries in a range of blocks:

      • Config file should have the names of queries to be fired along with the corresponding entity names.

        [queries]
          queryDir = "../graph-test-watcher/src/gql/queries"
          [queries.names]
            author = "Author"
            blog = "Blog"
        

        The queries will be fired if the corresponding entities are updated.

      • Run the CLI:

        ./bin/compare-blocks --config-file environments/compare-cli-config.toml --start-block 1 --end-block 10
        
      • For comparing entities after fetching updated entity ids from watcher database:

        • Set the watcher config file path and entities directory.

          [endpoints]
            gqlEndpoint1 = "http://localhost:8000/subgraphs/name/example1"
            gqlEndpoint2 = "http://localhost:3008/graphql"
          
          [queries]
            queryDir = "../graph-test-watcher/src/gql/queries"
            [queries.names]
              author = "Author"
              blog = "Blog"
          
          [watcher]
            configPath = "../../graph-test-watcher/environments/local.toml"
            entitiesDir = "../../graph-test-watcher/dist/entity/*"
          
        • To verify diff State state generated at each block, set the watcher endpoint and verifyState flag to true

          [watcher]
            configPath = "../../graph-test-watcher/environments/local.toml"
            entitiesDir = "../../graph-test-watcher/dist/entity/*"
            endpoint = "gqlEndpoint2"
            verifyState = true
          
        • Run the CLI with fetch-ids flag set to true:\

          ./bin/compare-blocks --config-file environments/compare-cli-config.toml --start-block 1 --end-block 10 --fetch-ids
          

Dependencies

Dependencies

ID Version
@apollo/client ^3.3.19
@cerc-io/assemblyscript 0.19.10-watcher-ts-0.1.2
@cerc-io/cache ^0.2.107
@cerc-io/ipld-eth-client ^0.2.107
@cerc-io/util ^0.2.107
@types/json-diff ^0.5.2
@types/yargs ^17.0.0
bn.js ^4.11.9
debug ^4.3.1
fs-extra ^10.0.0
graphql ^15.5.0
json-diff ^0.5.4
lodash ^4.17.21
omit-deep ^0.3.0
pluralize ^8.0.0
reflect-metadata ^0.1.13
toml ^3.0.0
typeorm 0.2.37
typeorm-naming-strategies ^2.0.0
yargs ^17.0.1

Development Dependencies

ID Version
@cerc-io/solidity-mapper ^0.2.107
@ethersproject/providers ^5.4.4
@graphprotocol/graph-ts ^0.22.0
@nomiclabs/hardhat-ethers ^2.0.2
@nomiclabs/hardhat-waffle ^2.0.1
@types/chai ^4.2.18
@types/chai-spies ^1.0.3
@types/lodash ^4.14.168
@types/pluralize ^0.0.29
@typescript-eslint/eslint-plugin ^5.47.1
@typescript-eslint/parser ^5.47.1
chai ^4.3.4
chai-spies ^1.0.0
eslint ^8.35.0
eslint-config-semistandard ^15.0.1
eslint-config-standard ^16.0.3
eslint-plugin-import ^2.27.5
eslint-plugin-node ^11.1.0
eslint-plugin-promise ^5.1.0
eslint-plugin-standard ^5.0.0
ethers ^5.4.4
hardhat ^2.3.0
mocha ^8.4.0
nodemon ^2.0.7
ts-node ^10.2.1
typescript ^5.0.2
Details
npm
2024-09-18 10:11:52 +00:00
1
AGPL-3.0
latest
43 KiB
Assets (1)
Versions (85) View all
0.2.107 2024-09-18
0.2.106 2024-08-02
0.2.105 2024-08-01
0.2.104 2024-07-19
0.2.103 2024-07-12