Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subgraph Composition : Fix graph init for composed subgraphs #1920

Merged
merged 22 commits into from
Feb 13, 2025

Conversation

incrypto32
Copy link
Member

@incrypto32 incrypto32 commented Jan 27, 2025

This PR enables graph init for composed subgraphs. It creates a new ipfs client to validate the source subgraph manifest

Copy link

changeset-bot bot commented Jan 27, 2025

🦋 Changeset detected

Latest commit: 36cf7e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphprotocol/graph-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 27, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphprotocol/graph-cli 0.96.0-alpha-20250210082839-dbaea17ad26cadc1adaaff578e4fcdf588367424 npm ↗︎ unpkg ↗︎

Copy link

cloudflare-workers-and-pages bot commented Jan 27, 2025

Deploying graph-tooling with  Cloudflare Pages  Cloudflare Pages

Latest commit: 36cf7e3
Status: ✅  Deploy successful!
Preview URL: https://c2beb640.graph-tooling.pages.dev
Branch Preview URL: https://krishna-comp-fixes.graph-tooling.pages.dev

View logs

@YaroShkvorets
Copy link
Collaborator

@incrypto32 could you fix the linter error?

@YaroShkvorets
Copy link
Collaborator

I think there are some issues with running github actions in your branch after #1919

Rebasing on top of the latest main should help.

@incrypto32
Copy link
Member Author

@YaroShkvorets i just rebase on top of main and the issue persists. I cant figure out what the lint issue is, also im not able to run the lint locally. Getting these error


Oops! Something went wrong! :(

ESLint: 9.19.0

Error: Cannot read config file: /Users/krishna/dev/work/edgeandnode/thegraph/graph-tooling/node_modules/.pnpm/@theguild+eslint-config@0.13.2_eslint@9.16.0_jiti@2.4.1__typescript@5.7.2/node_modules/@theguild/eslint-config/src/index.js
Error: Failed to patch ESLint because the calling module was not recognized.
If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:
https://github.com/microsoft/rushstack/issues
Referenced from: 
    at Object.<anonymous> (/Users/krishna/dev/work/edgeandnode/thegraph/graph-tooling/node_modules/.pnpm/@rushstack+eslint-patch@1.10.4/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:167:19)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/krishna/dev/work/edgeandnode/thegraph/graph-tooling/node_modules/.pnpm/@rushstack+eslint-patch@1.10.4/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:11:23)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    
    ```

@YaroShkvorets
Copy link
Collaborator

Looks like it's passing. Good for review now?

@incrypto32
Copy link
Member Author

@YaroShkvorets yes, ready for review

Copy link
Collaborator

@YaroShkvorets YaroShkvorets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Remove hidden: true from --ipfs flag on line 117
  • There doesn't seem to be a way to scaffold a subgraph-based subgraph in non-interactive way from command line. Is it possible?
  • this command does nothing and exits with code 0 without any error: graph init test test --from-contract=0x0 --protocol=subgraph --network=mainnet

@incrypto32
Copy link
Member Author

@YaroShkvorets just addressed the comments, the CI is failing but i think its not related to the code.

@YaroShkvorets
Copy link
Collaborator

@incrypto32 A couple of things:

  • Remove hidden: true from --ipfs flag on line 117
  • It always defaults to startBlock=0. I think it would be good DevEx if it defaulted to minimum startBlock from the source subgraph data sources.
  • There doesn't seem to be a way to scaffold a subgraph-based subgraph in non-interactive way from command line. Is it possible?

@incrypto32
Copy link
Member Author

@YaroShkvorets I just added the support for non interactive mode and addressed the other comments too.

Copy link
Collaborator

@YaroShkvorets YaroShkvorets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. --from-source-subgraph is fine by me, but wouldn't --from-subgraph be more concise? "source" seems redundant.

  2. If you don't specify --start-block in non-interactive mode, it goes with undefined:

❯ graph init usdt usdt --from-source-subgraph QmaNwrB6x9oiB2NZkbPsSjkCWhMT7gzH3NKYR8ESYpcyNW --protocol subgraph --network mainnet
  Generate subgraph
  Write subgraph to directory
✔ Create subgraph scaffold
✔ Initialize subgraph repository
✔ Install dependencies with yarn
✖ Failed to generate code from ABI and GraphQL schema: Command failed: yarn codegen
- Apply migrations
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
- Apply migrations
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
- Apply migrations
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
- Apply migrations
  Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
- Apply migrations
  Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
- Apply migrations
  Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
- Apply migrations
  Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
- Apply migrations
✔ Apply migrations
- Load subgraph from subgraph.yaml
✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml:

  Path: dataSources > 0 > source > startBlock
  Expected BigInt, found string:
  undefined
error Command failed with exit code 1.

Copy link
Collaborator

@YaroShkvorets YaroShkvorets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a commit to fix protocol validation. The rest looks good. Flag validation is getting out of hand for this command. Created an issue to address it separately: #1952

One last thing, let's add a test to init.test.ts

@YaroShkvorets
Copy link
Collaborator

Wonder why CI workflows are not running. Works for other PRs.

@YaroShkvorets YaroShkvorets merged commit b6d7f1c into main Feb 13, 2025
1 check passed
@YaroShkvorets YaroShkvorets deleted the krishna/comp-fixes branch February 13, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants