entc/gen: add support for WithNamed<E> feature-flag (#2792)

* entc/gen: struct fields and methods for NamedEdge api

* entc/gen: generate WithNamedEdge methods for named-edges

* entc/gen: implement eager-loading for named-edges

* entc/gen: simplify eager-loading template

* entc/gen: drop support for unqiue edges in named-based loading

* all: codegen

* doc/website: named-edges feature-flag

* Update doc/md/eager-load.mdx

* Update doc/md/eager-load.mdx
This commit is contained in:
Ariel Mashraki
2022-07-24 18:41:07 +03:00
committed by GitHub
parent a2b18f24f0
commit b60e0f9eac
187 changed files with 1791 additions and 679 deletions

View File

@@ -45,8 +45,7 @@ type GroupEdges struct {
func (e GroupEdges) TenantOrErr() (*Tenant, error) {
if e.loadedTypes[0] {
if e.Tenant == nil {
// The edge tenant was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: tenant.Label}
}
return e.Tenant, nil

View File

@@ -31,7 +31,6 @@ type GroupQuery struct {
order []OrderFunc
fields []string
predicates []predicate.Group
// eager-loading edges.
withTenant *TenantQuery
withUsers *UserQuery
// intermediate query (i.e. traversal path).

View File

@@ -48,8 +48,7 @@ type UserEdges struct {
func (e UserEdges) TenantOrErr() (*Tenant, error) {
if e.loadedTypes[0] {
if e.Tenant == nil {
// The edge tenant was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: tenant.Label}
}
return e.Tenant, nil

View File

@@ -31,7 +31,6 @@ type UserQuery struct {
order []OrderFunc
fields []string
predicates []predicate.User
// eager-loading edges.
withTenant *TenantQuery
withGroups *GroupQuery
// intermediate query (i.e. traversal path).