apiVersion upgrade across all impacted Graph Protocol projects. API versions control the features and behaviors available to subgraph developers.
Overview
An API version upgrade affects multiple repositories in the Graph Protocol ecosystem:graph-node- Core indexing protocolgraph-ts- AssemblyScript runtime librarygraph-cli- Command-line toolsgraph-docs- Documentation site
All steps should be taken after relevant
graph-node changes have been rolled out to production (hosted-service).Prerequisites
- All new features and breaking changes must be implemented in
graph-node - Changes must be deployed and stable in production
- Test coverage for new features must be in place
Steps
If you’re setting the environment variable manually elsewhere, update or remove those configurations.
The
GRAPH_MAX_API_VERSION determines which API features are available to subgraphs. Subgraphs declaring a higher API version than supported will fail validation.graph-node minor version in Cargo.toml- New API features
- Breaking changes
- Migration guide
package.jsonWrite Migrations
Create migration scripts for the newapiVersion to help developers upgrade their subgraphs:Update Version Restrictions
Update version restrictions onbuild and deploy commands to match the new graph-ts and apiVersion:Update Package Version
Update thegraph-cli version in package.json:Update Scaffolded Code
Updategraph-ts and graph-cli version numbers in:- Scaffold templates
- Example subgraphs
- Documentation examples
Recompile Examples
Recompile all example subgraphs:Create CLI Release
- Update version and create git tag
- Generate release notes
- Create GitHub release
Publish to NPM
API Version Architecture
How API Versions Work
API versions in Graph Node use semantic versioning and control:- Available host functions in the WASM runtime
- Data types and interfaces
- Query capabilities
- Validation rules
Version Checking
The version check happens during subgraph deployment:Runtime Behavior
Different API versions can have different runtime behavior:Extension Points
Adding New Host Functions
When adding host functions that require a new API version:- Implement in graph-node: Add the function to the runtime host exports
- Update graph-ts: Add TypeScript/AssemblyScript bindings
- Gate by version: Check API version before allowing usage
Deprecating Features
To deprecate features:- Document deprecation in release notes
- Add warnings when old API versions are used
- Provide migration path
- Remove after sufficient grace period
Testing
Unit Tests
Test API version validation:Integration Tests
Test subgraph deployment with different API versions:Compatibility Matrix
Maintain a compatibility matrix:| graph-node | graph-ts | graph-cli | API Version |
|---|---|---|---|
| 0.34.0 | 0.31.0 | 0.60.0 | 0.0.8 |
| 0.33.0 | 0.30.0 | 0.59.0 | 0.0.7 |
Rollback Procedure
If issues are discovered:- Revert the
GRAPH_MAX_API_VERSIONchange - Deploy hotfix to production
- Communicate with subgraph developers
- Address issues before re-attempting upgrade
Best Practices
- Backward Compatibility: Maintain compatibility with older API versions when possible
- Gradual Rollout: Test in staging before production
- Clear Documentation: Provide detailed migration guides
- Version Pinning: Allow users to pin to specific versions
- Breaking Changes: Minimize breaking changes between versions
Common Issues
Subgraph Fails After Upgrade
Symptom: Subgraph stops syncing after API version upgrade Solution: Check compatibility, review breaking changes, update mapping codeBuild Failures
Symptom:graph build fails with version mismatch
Solution: Ensure graph-ts and graph-cli versions are compatible

