Skip to content

Instantly share code, notes, and snippets.

@manakuro
Created December 10, 2021 05:08
Show Gist options
  • Save manakuro/0f5fc126e0d414c1bb3e2e4010681c3f to your computer and use it in GitHub Desktop.
Save manakuro/0f5fc126e0d414c1bb3e2e4010681c3f to your computer and use it in GitHub Desktop.
package repository
import (
"context"
"golang-clean-architecture-ent-gqlgen/ent"
)
// WithTransactionalMutation automatically wrap the GraphQL mutations with a database transaction.
// This allows the ent.Client to commit at the end, or rollback the transaction in case of a GraphQL error.
func WithTransactionalMutation(ctx context.Context) *ent.Client {
return ent.FromContext(ctx)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment