Skip to content

Conversation

@incrypto32
Copy link
Member

@incrypto32 incrypto32 commented Nov 5, 2024

This PR adds new types for subgraph datasources to graph-ts and codegen functionality to generate schema code for the source subgraphs.
Detailed docs about subgraph datasources here.

This PR

  1. Adds support to parse the new type of datasource in the manifest
  2. Adds the new EntityTrigger type to graph-ts which is the Assemblyscript represenation of entity triggers.
  3. Adds an enum EntityOp which represents the entity operations done on the source subgraph
  4. Runs codegen for the schema of source subgraphs so that dependant subgraph also has access to entity types from source subgraphs

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2024

🦋 Changeset detected

Latest commit: b75cda9

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

This PR includes changesets to release 2 packages
Name Type
@graphprotocol/graph-cli Minor
@graphprotocol/graph-ts 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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2024

🚀 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.91.0-alpha-20241129215038-b75cda9 npm ↗︎ unpkg ↗︎
@graphprotocol/graph-ts 0.36.0-alpha-20241129215038-b75cda9 npm ↗︎ unpkg ↗︎

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 5, 2024

Deploying graph-tooling with  Cloudflare Pages  Cloudflare Pages

Latest commit: b75cda9
Status: ✅  Deploy successful!
Preview URL: https://f66a91d8.graph-tooling.pages.dev
Branch Preview URL: https://feat-subgraph-composition.graph-tooling.pages.dev

View logs

@0237h
Copy link
Collaborator

0237h commented Nov 5, 2024

Hey @incrypto32, thanks for the PR !

Gonna take a bit of time to review. In the meantime if you can provide some more context/information as to what these feature would bring to developers, would be very much appreciated thanks 👍

@0237h
Copy link
Collaborator

0237h commented Nov 7, 2024

Given the context, we'll also wait for some of the related PRs in graph-node to be merged before merging this one as well.

@incrypto32
Copy link
Member Author

Hey @0237h , i'll write up the required context soon. TL;DR is this will support the code generation and the new type of datasource thats being added as part of the subgraph composition feature. As you mentioned. Yes those graph-node PR's need to be merge before getting this out. I'll write a detailed comment on the changes later.

@incrypto32
Copy link
Member Author

@0237h I just added a description to the PR. let me know if more info is needed

Copy link
Collaborator

@0237h 0237h left a comment

Choose a reason for hiding this comment

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

@incrypto32 Thanks for the updated description !

A few minor comments, other LGTM.
Do you know if the graph-node integration for subgraph datasources is also ready ?

@YaroShkvorets
Copy link
Collaborator

YaroShkvorets commented Nov 22, 2024

Doesn't seem to work for me. After running graph init and selecting "subgraph" as a protocol it tries to download ABI for I don't know what. I assume it shouldn't, since I never specified the contract address?
What's the flow here @incrypto32 ?

image

@incrypto32
Copy link
Member Author

Oops, i think i didn't check the graph init support just the codegen and build. I tested with an existing subgraph that i modified to use the new datasource.
Thanks for testing it out @YaroShkvorets, i'll add the init support too.

@incrypto32
Copy link
Member Author

@YaroShkvorets just added the init command. Please re review

@YaroShkvorets
Copy link
Collaborator

❯ ./bin/run init --skip-install --skip-git
 ›   Warning: @graphprotocol/graph-cli update available from 0.87.0 to 0.90.1.
 ›   Warning: In next major version, this flag will be removed. By default we will stop initializing a Git repository.
✔ Protocol · subgraph
✔ Subgraph slug · asdf
✔ Directory to create the subgraph in · asdf
? Subgraph network …
? Subgraph network …
? Subgraph network …
✔ Subgraph network · mainnet
✔ Source subgraph identifier · QmTZ8ejXJxRo7vDBS4uwqBeGoxLSWbhaA7oXa1RvxunLy7
✔ IPFS node to use for fetching subgraph manifest · https://api.thegraph.com/ipfs/api/v0
✔ Start Block · 0
  Generate subgraph
✖ Failed to create subgraph scaffold: Cannot read properties of undefined (reading 'length')
    TypeError: Cannot read properties of undefined (reading 'length')

@YaroShkvorets
Copy link
Collaborator

Let's merge it @0237h , then let @incrypto32 polish out any bugs.
There is a lot of overlap with what I'm doing so I don't want to keep this PR open much longer to avoid merge hell.

@YaroShkvorets YaroShkvorets self-requested a review November 29, 2024 21:33
@0237h 0237h merged commit 2050bf6 into main Nov 29, 2024
10 checks passed
@0237h 0237h deleted the feat-subgraph-composition branch November 29, 2024 22:03
@incrypto32
Copy link
Member Author

@YaroShkvorets as will this be released soon?
Actually we need to wait before releasing this for the graph-node PR's to be merged. cc: @alex-pakalniskis
#1754 (comment)

@YaroShkvorets
Copy link
Collaborator

Yes, let's coordinate on the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants