Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@graphprotocol/graph-cli

graphprotocol118.2k(Apache-2.0 OR MIT)0.97.0TypeScript support: included

CLI for building for and deploying to The Graph

readme

The Graph Tooling

Monorepo for various tools used by subgraph developers.

This repository houses the following tools:

NPM Name
npm (scoped) @graphprotocol/graph-cli
npm (scoped) @graphprotocol/graph-ts

Contributing

We welcome contributions to this repository. Please follow the Code of Conduct for all the communications.

To run this project locally:

  1. Clone the repository
  2. Make sure you have Node.js >=20.x installed
  3. Make sure you have pnpm installed
  4. Run pnpm install to install dependencies
  5. Run pnpm build to build the packages
  6. Run pnpm test to run the tests

Release process

We use changeset to manage releases. Every PR should include a changeset file. The release process is as follows:

  1. Author creates the PR with changes and runs pnpm changeset to create a changeset file to summarize the changes.
  2. When the PR is merged to main, a Github Action will run and create a PR with the version bump and changelog.
  3. We will merge the bot generated PR to main.
  4. A Github Action will run and publish the new version to npm.

Helpful links:

Stable release example

When PRs are merged and to main we can choose to merge the bot generated changeset PR to main and it will publish a new version to npm.

Example of a graph-client release: https://github.com/graphprotocol/graph-client/pull/295

Alpha release example

Every PR to main that includes a changeset file will create a new alpha version.

Example of graph-client snapshot release: https://github.com/graphprotocol/graph-client/pull/178#issuecomment-1214822036

License

Copyright © 2018-2019 Graph Protocol, Inc. and contributors.

The Graph CLI is dual-licensed under the MIT license and the Apache License, Version 2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License.

changelog

@graphprotocol/graph-cli

0.97.0

Minor Changes

  • #1993 3e04952 Thanks @incrypto32! - Composed subgraphs are modified to only accept immutable entites as triggers from a source subgraph

  • #1994 2946073 Thanks @isum! - require immutable flag on entities

Patch Changes

0.96.0

Minor Changes

Patch Changes

0.95.0

Minor Changes

Patch Changes

0.94.0

Minor Changes

Patch Changes

0.93.3

Patch Changes

0.93.2

Patch Changes

0.93.1

Patch Changes

0.93.0

Minor Changes

  • #1849 00e0a83 Thanks @YaroShkvorets! - Update all dependencies

  • #1849 00e0a83 Thanks @YaroShkvorets! - - add networks registry support

    • improve graph init flow
      • filter through the networks as you type
      • more information about the networks
      • remove unnecessary options depending on the selection
      • ESC key to go back
    • allow specifying ipfs/url for substreams package

Patch Changes

0.92.0

Minor Changes

  • #1843 c09b56b Thanks @YaroShkvorets! - Update all dependencies

  • #1843 c09b56b Thanks @YaroShkvorets! - - add networks registry support

    • improve graph init flow
      • filter through the networks as you type
      • more information about the networks
      • remove unnecessary options depending on the selection
      • ESC key to go back
    • allow specifying ipfs/url for substreams package

Patch Changes

0.91.1

Patch Changes

0.91.0

Minor Changes

0.90.1

Patch Changes

0.90.0

Minor Changes

  • 098b433 Thanks @DenisCarriere! - Update deprecated endpoints and support API key for updating published subgraphs

Patch Changes

  • #1771 93271b0 Thanks @0237h! - Support parsing full path contract name from block explorers

  • #1774 5d9f0c9 Thanks @0237h! - Add new chains: abstract-testnet, corn and corn-testnet

  • #1767 6f2cb45 Thanks @0237h! - Fix CLI validation for startBlock and contractName fetched from external APIs

0.89.0

Minor Changes

Patch Changes

0.88.0

Minor Changes

  • #1680 08914a8 Thanks @saihaj! - Breaking changes to the CLI to prepare for the sunset of the hosted service.

    • graph auth
      • Removed --product flag
      • Removed --studio flag
      • Removed node argument
    • graph deploy
      • Removed --product flag
      • Removed --studio flag
      • Removed --from-hosted-service flag
    • graph init
      • Removed --product flag
      • Removed --studio flag
      • Removed --allow-simple-name flag
  • #1749 bf43cbf Thanks @0237h! - Add warning for available CLI updates

Patch Changes

0.87.0

Minor Changes

0.86.0

Minor Changes

0.85.0

Minor Changes

0.84.0

Minor Changes

0.83.0

Minor Changes

0.82.0

Minor Changes

0.81.0

Minor Changes

0.80.1

Patch Changes

0.80.0

Minor Changes

0.79.2

Patch Changes

0.79.1

Patch Changes

0.79.0

Minor Changes

  • #1696 828bb04 Thanks @alinobrasil! - added rpc & explorer urls for sei, gravity (mainnet & testnet), etherlink (mainnet)

0.78.0

Minor Changes

0.77.0

Minor Changes

0.76.0

Minor Changes

0.75.0

Minor Changes

  • #1686 fea8f23 Thanks @alinobrasil! - getEtherscanLikeAPIUrl: added for sei mainnet (to be able to obtain contract ABI)

0.74.1

Patch Changes

0.74.0

Minor Changes

  • #1681 0a16b41 Thanks @saihaj! - Part of the Hosted Service migration throw an error when users are trying to use hosted-service product in graph [auth|deploy|init] commands.

Patch Changes

0.73.0

Minor Changes

  • #1670 03c907a Thanks @saihaj! - Introduce graph publish command.

    Now you can publish your subgraphs directly from the CLI. This command will build your subgraph, deploy, prompt you to add metadata and then sign the transaction to publish it to the Graph Network.

    1. Build the subgraph and publish it to the network.
    graph publish
    1. Provide a IPFS Hash for the subgraph and publish it to the network.
    graph publish --ipfs <ipfs-hash>
    1. You can use a custom webapp url for deploying.
    graph publish --webapp-url <webapp-url>

Patch Changes

0.72.2

Patch Changes

0.72.1

Patch Changes

0.72.0

Minor Changes

Patch Changes

0.71.2

Patch Changes

0.71.1

Patch Changes

0.71.0

Minor Changes

Patch Changes

  • #1634 f256475 Thanks @joshuanazareth97! - Order list of evm chains in graph init command

  • #1640 1fb675c Thanks @Shiyasmohd! - Added Etherscan like API url and Public RPC endpoints for Polygon Amoy,Gnosis Chiado,Mode Mainnet, Mode Sepolia chains for fetching startBlock and ABI

0.70.0

Minor Changes

0.69.2

Patch Changes

0.69.1

Patch Changes

0.69.0

Minor Changes

0.68.5

Patch Changes

0.68.4

Patch Changes

0.68.3

Patch Changes

0.68.2

Patch Changes

0.68.1

Patch Changes

0.68.0

Minor Changes

  • #1548 b3f6a99 Thanks @lutter! - Make validations more lenient to allow aggregations and Int8 ids

0.67.4

Patch Changes

0.67.3

Patch Changes

0.67.2

Patch Changes

0.67.1

Patch Changes

0.67.0

Minor Changes

Patch Changes

0.66.0

Minor Changes

0.65.0

Minor Changes

0.64.1

Patch Changes

0.64.0

Minor Changes

Patch Changes

0.63.1

Patch Changes

0.63.0

Minor Changes

Patch Changes

0.62.0

Minor Changes

Patch Changes

0.61.0

Minor Changes

0.60.0

Minor Changes

0.59.0

Minor Changes

Patch Changes

0.58.0

Minor Changes

0.57.0

Minor Changes

  • #1439 b583097 Thanks @saihaj! - Enable autocomplete for CLI commands. To configure run

    graph autocomplete

    and follow the steps in the prompt.

  • #1441 2e656e9 Thanks @saihaj! - show suggestions when an invalid command is entered

Patch Changes

0.56.0

Minor Changes

0.55.0

Minor Changes

  • #1419 e88ff02 Thanks @saihaj! - Introduce --from-hosted-service flag which will make it easier to deploy subgraphs from hosted service to Studio.

  • #1418 38c16be Thanks @uF4No! - feat: adds zksync era testnet

0.54.0

Minor Changes

Patch Changes

0.53.0

Minor Changes

Patch Changes

  • #1400 e7423aa Thanks @saihaj! - only update network.json file during graph add if it exists

  • #1402 f0ce6c0 Thanks @saihaj! - show a descriptive error message and do not hang if there is a deploy key issue

  • #1403 dfa9ee1 Thanks @saihaj! - do not ask for local path when trying to add more contracts during init

  • #1400 e7423aa Thanks @saihaj! - ask for start block in graph add if we cannot fetch the start block from etherscan

0.52.0

Minor Changes

Patch Changes

0.51.2

Patch Changes

0.51.1

Patch Changes

  • #1369 18e5c29 Thanks @azf20! - fix: always create output directory on building a subgraph

0.51.0

Minor Changes

  • #1340 2375877 Thanks @incrypto32! - Add support for codegen for derived field loaders, This adds getters for derived fields defined in the schema for entities.

  • #1363 f928262 Thanks @saihaj! - add graph clean command to delete generated artifacts

  • #1296 dab4ca1 Thanks @dotansimha! - Added support for handling GraphQL Int8 scalar as i64 (AssemblyScript)

0.50.1

Patch Changes

0.50.0

Minor Changes

  • #1353 125c687 Thanks @saihaj! - Add a new --ipfs-hash flag to graph deploy allowing to deploy a subgraph that is already compiled and uploaded to IPFS.

  • #1335 7343f50 Thanks @saihaj! - For substreams generate the directory tree as follows

    .
    ├── package.json
    ├── schema.graphql
    └── subgraph.yaml

    In the package.json we only depend on the CLI since that is what developer will use to deploy the subgraph. The schema.graphql is the schema of the subgraph and the subgraph.yaml is the manifest file for the subgraph.

  • #1335 7343f50 Thanks @saihaj! - respect --abi flag instead of loading from etherscan

  • #1335 7343f50 Thanks @saihaj! - remove index events as entities for substreams

  • #1335 7343f50 Thanks @saihaj! - remove start block selection for substreams

  • #1343 032d703 Thanks @saihaj! - add SPK input for substreams protocol

Patch Changes

0.49.0

Minor Changes

  • #1327 a70ac44 Thanks @saihaj! - do not generate types, instead show a message to user to use substreams CLI for codegen.

  • #1306 f5e4b58 Thanks @saihaj! - Add loadInBlock function for entities as part of codegen

  • #1339 214cd71 Thanks @saihaj! - allow deploy optimism and optimism-goerli on studio

Patch Changes

0.48.0

Minor Changes

0.47.2

Patch Changes

0.47.1

Patch Changes

0.47.0

Minor Changes

  • #1284 b4311d8 Thanks @saihaj! - Changing code generation so we reduce the non-null assertions for primitive types. This way we can return null for primitive types and still have the generated code compile.

  • #1293 9ae82b5 Thanks @enisdenjo! - Include declaration files

  • #1258 86e1fda Thanks @saihaj! - validate existence for handlers specified in manifest during build

  • #1294 e5c1fbc Thanks @enisdenjo! - Prompt deploy command for subgraph name and select product

Patch Changes

0.46.1

Patch Changes

0.46.0

Minor Changes

0.45.2

Patch Changes

0.45.1

Patch Changes

0.45.0

Minor Changes

  • #1225 3f9aa1c Thanks @saihaj! - When the contract has an id event, the CLI renames the id entity to {contractName}_id and map it to {contractName}_id in the mapping.

  • #1209 f26398e Thanks @kalloc! - Support ts typing in tests folder

Patch Changes

0.44.0

Minor Changes

Patch Changes

  • #1201 f87e54c Thanks @saihaj! - read testsFolder from matchstick yaml and set the paths based on that

  • #1201 f87e54c Thanks @saihaj! - make datasource and version optional args for test command

  • 876bc52 Thanks @saihaj! - Allow file data sources (with no network) to deploy to the studio. File data sources don't have a network specified.

  • #1197 b52e3b1 Thanks @saihaj! - make generated list children non-nullable

  • #1193 c240588 Thanks @saihaj! - do not generate setters for derived fields

0.43.0

Minor Changes

0.42.4

Patch Changes

0.42.3

Patch Changes

0.42.2

Patch Changes

0.42.1

Patch Changes

0.42.0

Minor Changes

Patch Changes

  • #1127 b8d2297 Thanks @saihaj! - Prioirtize node flag. If provided we do not need to go lookup what product to deploy to

0.41.1

Patch Changes

0.41.0

Minor Changes

Patch Changes

0.40.0

Minor Changes

0.39.0

Minor Changes

Patch Changes

0.38.0

Minor Changes

0.37.7

Patch Changes

0.37.6

Patch Changes

0.37.5

Patch Changes

0.37.4

Patch Changes

0.37.3

Patch Changes

0.37.2

Patch Changes

0.37.1

Patch Changes