feat: migrate to new embedded Dgraph client and add validation support#7
Merged
matthewmcneely merged 7 commits intomainfrom Feb 13, 2026
Merged
Conversation
Major refactoring to replace the old embedded server implementation with the new Dgraph v25 embedded client architecture, providing better performance and stability for in-process deployments. **Breaking Changes:** - Replaced `buf_server.go` with new `embedded_client.go` implementation - Updated all import paths from `github.com/hypermodeinc/dgraph` to `github.com/dgraph-io/dgraph` - Client initialization now uses the new embedded client architecture **New Features:** - Add comprehensive validation support using `github.com/go-playground/validator/v10` - New `WithValidator()` client option for custom validation rules - Validation integrated into Insert, Update, and Upsert operations - Support for custom validation functions and struct tags **Enhanced Test Coverage:** - Added `validate_test.go` with comprehensive validation test suite - Enhanced `update_test.go` and `upsert_test.go` with more test cases - Improved error handling and edge case testing - Added tests for custom validation rules and partial validation failures **Dependency Updates:** - Updated Dgraph dependencies to v25 stable release - Upgraded Go modules to latest stable versions - Updated gRPC to v1.78.0 for better performance - Refreshed all indirect dependencies for security and stability **Performance Improvements:** - Optimized embedded client connection handling - Improved mutation performance with better error handling - Enhanced query execution with the new embedded client **Bug Fixes:** - Fixed import paths for Dgraph v25 compatibility - Resolved connection issues in embedded mode - Improved error messages for validation failures - Fixed test cases that were assuming order in assertions **Documentation:** - Updated README.md with new embedded client usage examples - Clarified connection string formats for file vs Dgraph URIs - Added validation examples and best practices This migration provides a more stable foundation for embedded deployments while maintaining full backward compatibility for remote Dgraph connections.
There was a problem hiding this comment.
3 issues found across 34 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="engine.go">
<violation number="1" location="engine.go:553">
P2: The `commitOrAbort` function always uses `engine.db0` (default namespace) instead of the namespace associated with the transaction. When `embeddedDgraphClient.CommitOrAbort` calls this method, the client's namespace (`c.ns`) is ignored, which could cause commits to target the wrong namespace in multi-namespace scenarios.</violation>
</file>
<file name="README.md">
<violation number="1" location="README.md:165">
P3: The heading lists `WithValidator(Validator)`, but the API expects a `StructValidator` (or *validator.Validate implementing it). This mismatch can mislead users about the correct type. Rename the heading to match the actual interface.</violation>
</file>
<file name="client.go">
<violation number="1" location="client.go:276">
P2: Ignoring errors from `engine.GetNamespace` can leave `ns` nil, which will panic when the embedded client calls `c.ns.ID()` for an invalid/unknown namespace. Return the namespace lookup error instead of discarding it.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="client_test.go">
<violation number="1" location="client_test.go:444">
P3: The test only asserts when err != nil, so invalid namespaces can pass silently if NewClient returns nil. Always assert an error (after handling the singleton skip) to avoid false negatives.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Major refactoring to replace the old embedded server implementation with the new
Dgraph v25 embedded client architecture, providing better performance and
stability for in-process deployments.
Breaking Changes:
buf_server.gowith newembedded_client.goimplementationgithub.com/hypermodeinc/dgraphtogithub.com/dgraph-io/dgraphNew Features:
github.com/go-playground/validator/v10WithValidator()client option for custom validation rulesEnhanced Test Coverage:
validate_test.gowith comprehensive validation test suiteupdate_test.goandupsert_test.gowith more test casesDependency Updates:
Performance Improvements:
Bug Fixes:
Documentation:
This migration provides a more stable foundation for embedded deployments
while maintaining full backward compatibility for remote Dgraph connections.
Checklist
CHANGELOG.mdfile describing and linking tothis PR
Summary by cubic
Migrates embedded mode to the Dgraph v25 embedded client for faster, more stable in-process use, and adds entity validation via WithValidator across insert, update, and upsert. Updates to the latest Dgraph v25 build and refreshes README docs.
New Features
Migration
Written for commit 20b9f97. Summary will update on new commits.