-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: Add support for string-based namespaces from gRPC clients #9433
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: main
Are you sure you want to change the base?
feat: Add support for string-based namespaces from gRPC clients #9433
Conversation
358d02c
to
2897959
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.
Pull Request Overview
This PR enables gRPC clients to pass string-based namespaces by extracting a "namespace-str"
header, resolving it to a numeric ID, and falling back to the existing JWT namespace logic in QueryNoGrpc
.
- Introduce
ExtractNamespaceStr
to parse string namespaces from incoming metadata - Update
QueryNoGrpc
to attempt string-to-ID resolution before defaulting to JWT-based namespace
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
x/x.go | Added ExtractNamespaceStr to read "namespace-str" from metadata |
edgraph/server.go | Modified QueryNoGrpc to resolve string namespaces and fallback |
Comments suppressed due to low confidence (2)
edgraph/server.go:1199
- Add unit tests for the new string-based namespace path in
QueryNoGrpc
to cover both successful resolution and the fallback to JWT namespace.
nsStr, err := x.ExtractNamespaceStr(ctx)
x/x.go:277
- The metadata key "namespace-str" is hard-coded in multiple places; consider defining it as a package-level constant to avoid typos and ensure consistency.
ns := md.Get("namespace-str")
Attach that namespace if found -- will be overwritten if JWL-ACLs namespaces are found
…ther than "not found"
03f7487
to
bedbb28
Compare
Description
This PR adds the ability for gRPC clients to create and execute transactions within v25's new string-based namespaces. Managing transactions manually is something common in many repos that use the Dgraph gRPC clients. This new functionality makes upgrading transaction-heavy code (that wants to use string-based namespaces) less cumbersome.
Check out the companion PR in the dgo repo that adds support on the client side along with tests.
Please explain the changes you made here.
Checklist
CHANGELOG.md
file describing and linking tothis PR