Grafting (Advanced)
You will learn how to build and deploy new subgraphs by grafting existing subgraphs.
For larger subgraphs or when continuously deploying smart contracts as part of a project, developers often encounter challenges when indexing a subgraph from its inception, which can lead to resource inefficiency and time consumption.
Overview
For more experienced developers, there is the option to utilize the Grafting feature. Grafting involves reusing data from a compatible existing subgraph and initiating indexing from a custom-defined later block. This approach can prove beneficial for:
- Testing new features within the underlying smart contract or subgraph entity
- Quickly addressing simple mapping errors during development
- Temporarily restoring functionality of an existing subgraph that has encountered issues
Schema Compatibility
The new grafted subgraph does not have to have an identical GraphQL schema as the old base subgraph. It only needs to be compatible with it. Acceptable schema deviations include:
- Adding or removing entity types
- Removing attributes from entity types
- Adding nullable attributes to entity types
- Turning non-nullable attributes into nullable attributes
- Adding values to enums
- Adding or removing interfaces
- Changing for which entity types an interface is implemented
Additional Resources
The Official Graph Documentation offers in-depth tutorials and documentation on how Grafting can be performed on a subgraph: