-
Notifications
You must be signed in to change notification settings - Fork 1k
Support struct field access in declarative calls #6099
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable overall, just some smaller things that should be addressed.
Either way, this PR should only be approved once @incrypto32 gives his ok to the removal of pq-sys
The PR also needs to update the docs here |
@lutter the pq-sys was added to build the postgres C code from source when building the |
@lutter, could you please re-review when you have a moment? A humble apology in verse: 🎭 Ode to Overzealous Optimization Oh Lutter, we must confess with shame, Your feedback on assertions weak, The struct field access now runs deep, So please forgive our coding dance, — Your overly enthusiastic contributors P.S. The core functionality remains the same, just with better error handling and stronger test assertions as you requested! 🚀 |
3f323ff
to
d9cc0c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, but especially the handling of named parameters should be improved so that most of the processing happens when the call expression is parsed.
And we'll need to bump the specVersion
5ea86f5
to
e4d12b3
Compare
@lutter I think the integration test failure is unrelated. Can you confirm? EDIT: Yes, it's also failing on Likely caused by a recent Let's update the block hashes? |
c7b58c8
to
e6dca00
Compare
@lutter I sloppily let Claude jam on your feedback unreviewed this time because I was busy with sth. else. Apologies if this is slop. |
f03f6d2
to
8b5ab6c
Compare
This commit implements support for struct field access in declarative calls, allowing subgraphs to access nested struct fields using dot notation. Key changes: - Add struct field access parsing and validation - Support arbitrary nesting depth for field access - Update subgraph manifest documentation - Add comprehensive tests for struct field access functionality - Update API version to support new feature
Addresses feedback from Lutter about supporting struct field access in declarative calls in production. Previously, manifest parsing happened via serde deserialize which called FromStr without ABI context, preventing named field resolution outside of tests. This implements two-phase parsing where: - Initial deserialization stores calls as raw strings in UnresolvedCallDecls - Resolution phase parses calls with ABI context using CallExpr::parse() - Spec version validation happens during parsing with clear error messages Changes: - Add UnresolvedCallDecls struct to store raw call strings - Add UnresolvedMappingEventHandler and UnresolvedEntityHandler - Move call parsing from deserialization to resolution phase - Replace eprintln! with proper logger.warn() calls - Remove obsolete validation functions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Implement complete support for named and mixed struct field access in declarative calls within subgraph manifests. This enables intuitive patterns like
event.params.asset.addr
instead of cryptic numeric indices likeevent.params.asset.0
.Key Features
event.params.asset.addr
(fully implemented with ABI integration)event.params.data.1.user.id
(unlimited depth)event.params.transfers.0.recipient
(numeric + named)Why This Implementation is Necessary
The ethabi crate has a significant limitation: tuple field names are completely lost during ABI parsing. While the original ABI JSON contains rich component information:
The ethabi parser converts this to
ParamType::Tuple(vec\![Address, Uint(256)])
, discarding the field names "addr" and "amount" entirely.Our solution works around this limitation by:
This indirection enables user-friendly named access while maintaining ethabi's type safety.
Architecture Changes
StructField(Word, Vec<FieldAccess>)
variant supporting both access patternsIndex(usize)
for numeric access,Name(Word)
for named accessMappingABI
extended withstruct_field_mappings
from ABI JSON parsingExample Usage
Error Message Improvements
Before:
After:
Implementation Status
✅ Complete Implementation: Full named field access with ABI integration
✅ Parser: Supports arbitrary nesting with mixed numeric/named patterns
✅ Field Resolution: ABI-driven name-to-index mapping with comprehensive error handling
✅ Integration: Event context propagated through entire call chain
✅ Test Coverage: 16 comprehensive tests (reduced from 19, eliminated redundancy)
✅ Documentation: Updated subgraph manifest docs with examples and usage patterns
✅ Backward Compatibility: All existing numeric access patterns preserved
Documentation Updates
Expr
table with all supported access patternsTest Plan
cargo fmt
Breaking Changes
None. All existing functionality preserved while adding new capabilities.
Related Issues
Addresses GitHub issue #6059 and reviewer feedback. Provides complete named struct field access functionality for Graph Node declarative calls with full documentation.
🤖 Generated with Claude Code