Skip to content

feat: Add string-based namespace support in Txns #262

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

matthewmcneely
Copy link
Member

Description

This PR adds string-based namespace support to the Txn class. Managing transactions manually is something common in many repos that use the dgo client. This new functionality makes upgrading transaction-heavy code (that wants to use string-based namespaces) less cumbersome.

Checklist

  • Code compiles correctly and linting passes locally
  • For all code changes, an entry added to the CHANGELOG.md file describing and linking to
    this PR
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

@Copilot Copilot AI review requested due to automatic review settings June 4, 2025 01:25
@matthewmcneely matthewmcneely requested a review from a team as a code owner June 4, 2025 01:25
Copy link

@Copilot Copilot AI left a 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 adds string‐based namespace support to transactions in the Txn class to simplify manual transaction management with the dgo client.

  • Introduces NewTxnInNamespace and NewReadOnlyTxnInNamespace methods in txn.go.
  • Adds comprehensive tests in v2_test.go and examples_test.go to verify namespace behavior.
  • Updates docker-compose.yml to include non‐ACL service configurations for testing.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
v2_test.go Adds tests for namespace creation, duplicate namespace error handling, and Txn usage.
txn.go Introduces new namespace field and helper methods for namespace-aware transactions.
t/docker-compose.yml Provides new docker services for a non‑ACL environment to support testing.
examples_test.go Adds functions to obtain dgo clients in non‑ACL mode and tests namespace support.
Comments suppressed due to low confidence (1)

txn.go:67

  • Correct the abbreviation 'Tnx' to 'Txn' for clarity in the comment.
// in the default namespace. Note that a Tnx created with this function will not complete successfully as the

@matthewmcneely matthewmcneely force-pushed the matthewmcneely/support-string-namespaces-in-txns branch from c7159b5 to 3f812cf Compare June 17, 2025 21:12
@RJKeevil
Copy link

RJKeevil commented Jun 25, 2025

I think this would be a great improvement.

With the V2 apis, namespaces are simple and a separate concept from ACL/auth, which is fantastic and exactly what I need. We have some graphs that update continuously, and others that are a monthly dump to be dropped and recreated in full. Namespaces gives me an easy way to acheive this data separation. I do not need different auth rules and user separation across the namespaces, as they are purely used by a single backend service.

The missing parts are to enable namespace selection everywhere, without requiring different logins. So dgo transactions, graphQL admin requests (upload schema etc), graphQL queries and the Ratel/play UI. Happy to add additional info if it helps!

See https://discuss.hypermode.com/t/v25-multitenency/19915/3

@RJKeevil
Copy link

Now that I understand that apiv2 currently deprecates json-based mutatations this change is very important, as I can fall back to legacy apis for these, provided I have a way to set namespaces, which this PR provides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants