feat: add SubscriptionOnCreate hook#1538
Conversation
📝 WalkthroughWalkthroughA new ChangesHookablePubsubDatasource SubscriptionOnCreate Hook
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@v2/pkg/engine/resolve/resolve_test.go`:
- Around line 6882-6884: Replace all instances of Context struct literal
construction with the NewContext() constructor function throughout the test
file. In v2/pkg/engine/resolve/resolve_test.go at lines 6882-6884 (anchor),
6915-6917, 6943-6945, 7055-7056, 7114-7115, and 7159-7160 (siblings), change
each occurrence of &Context{ctx: context.Background()} (or similar literal
construction) to NewContext(context.Background()) instead. After calling
NewContext(context.Background()), set only the required fields on the returned
Context object to ensure internal initialization invariants are preserved and
avoid brittle nil-field behavior as the resolver evolves.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2fe6af90-67f7-4a7a-9c35-9dcf41d7812c
📒 Files selected for processing (3)
v2/pkg/engine/resolve/datasource.gov2/pkg/engine/resolve/resolve.gov2/pkg/engine/resolve/resolve_test.go
Adds a new hook
SubscriptionOnCreate. That hook is part of the new interfaceHookablePubsubDatasource.This interface extends
HookableSubscriptionDataSourceand is meant to be implemented by Cosmo Streams (pubsub) datasources only. It means that in comparison with theSubscriptionOnStarthook,SubscriptionOnCreateis only called for Cosmo Streams datasources, not for normal subscription datasources.The hook is meant to modify subscription event data. The corresponding router pull request highlights the usecase wundergraph/cosmo#2972.
The changes here are meant to be backwards compatible. No breaking API changes are introduced. The routers pubsub datasource still implement
HookableSubscriptionDataSourceand that works the same as before. In order to make use of the new hook it needs to implementHookablePubsubDatasource.@coderabbitai summary
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.