entc/gen: add type for type edges (#318)

Will be used for adding methods on the struct edges
This commit is contained in:
Ariel Mashraki
2020-01-26 12:39:18 +02:00
committed by GitHub
parent 7c3bcde599
commit bc89ed4e0f
48 changed files with 437 additions and 294 deletions

View File

@@ -21,10 +21,13 @@ type Group struct {
ID int `json:"id,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupQuery when eager-loading is set.
Edges struct {
// Users holds the value of the users edge.
Users []*User
} `json:"edges"`
Edges GroupEdges `json:"edges"`
}
// GroupEdges holds the relations/edges for other nodes in the graph.
type GroupEdges struct {
// Users holds the value of the users edge.
Users []*User
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -21,17 +21,20 @@ type User struct {
ID int `json:"id,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Groups holds the value of the groups edge.
Groups []*Group
// Parent holds the value of the parent edge.
Parent *User
// Children holds the value of the children edge.
Children []*User
} `json:"edges"`
Edges UserEdges `json:"edges"`
parent_id *int
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Groups holds the value of the groups edge.
Groups []*Group
// Parent holds the value of the parent edge.
Parent *User
// Children holds the value of the children edge.
Children []*User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*User) scanValues() []interface{} {
return []interface{}{

View File

@@ -31,18 +31,21 @@ type Card struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CardQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
// Spec holds the value of the spec edge.
Spec []*Spec
} `json:"edges"`
Edges CardEdges `json:"edges"`
owner_id *string
// StaticField defined by templates.
StaticField string `json:"boring,omitempty"`
}
// CardEdges holds the relations/edges for other nodes in the graph.
type CardEdges struct {
// Owner holds the value of the owner edge.
Owner *User
// Spec holds the value of the spec edge.
Spec []*Spec
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Card) scanValues() []interface{} {
return []interface{}{

View File

@@ -30,17 +30,20 @@ type File struct {
Group string `json:"group,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the FileQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
// Type holds the value of the type edge.
Type *FileType
} `json:"edges"`
Edges FileEdges `json:"edges"`
type_id *string
group_file_id *string
owner_id *string
}
// FileEdges holds the relations/edges for other nodes in the graph.
type FileEdges struct {
// Owner holds the value of the owner edge.
Owner *User
// Type holds the value of the type edge.
Type *FileType
}
// scanValues returns the types for scanning values from sql.Rows.
func (*File) scanValues() []interface{} {
return []interface{}{

View File

@@ -24,10 +24,13 @@ type FileType struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the FileTypeQuery when eager-loading is set.
Edges struct {
// Files holds the value of the files edge.
Files []*File
} `json:"edges"`
Edges FileTypeEdges `json:"edges"`
}
// FileTypeEdges holds the relations/edges for other nodes in the graph.
type FileTypeEdges struct {
// Files holds the value of the files edge.
Files []*File
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -33,19 +33,22 @@ type Group struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupQuery when eager-loading is set.
Edges struct {
// Files holds the value of the files edge.
Files []*File
// Blocked holds the value of the blocked edge.
Blocked []*User
// Users holds the value of the users edge.
Users []*User
// Info holds the value of the info edge.
Info *GroupInfo
} `json:"edges"`
Edges GroupEdges `json:"edges"`
info_id *string
}
// GroupEdges holds the relations/edges for other nodes in the graph.
type GroupEdges struct {
// Files holds the value of the files edge.
Files []*File
// Blocked holds the value of the blocked edge.
Blocked []*User
// Users holds the value of the users edge.
Users []*User
// Info holds the value of the info edge.
Info *GroupInfo
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Group) scanValues() []interface{} {
return []interface{}{

View File

@@ -26,10 +26,13 @@ type GroupInfo struct {
MaxUsers int `json:"max_users,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupInfoQuery when eager-loading is set.
Edges struct {
// Groups holds the value of the groups edge.
Groups []*Group
} `json:"edges"`
Edges GroupInfoEdges `json:"edges"`
}
// GroupInfoEdges holds the relations/edges for other nodes in the graph.
type GroupInfoEdges struct {
// Groups holds the value of the groups edge.
Groups []*Group
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -24,15 +24,18 @@ type Node struct {
Value int `json:"value,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the NodeQuery when eager-loading is set.
Edges struct {
// Prev holds the value of the prev edge.
Prev *Node `gqlgen:prev`
// Next holds the value of the next edge.
Next *Node `gqlgen:next`
} `json:"edges"`
Edges NodeEdges `json:"edges"`
prev_id *string
}
// NodeEdges holds the relations/edges for other nodes in the graph.
type NodeEdges struct {
// Prev holds the value of the prev edge.
Prev *Node `gqlgen:prev`
// Next holds the value of the next edge.
Next *Node `gqlgen:next`
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Node) scanValues() []interface{} {
return []interface{}{

View File

@@ -24,16 +24,19 @@ type Pet struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PetQuery when eager-loading is set.
Edges struct {
// Team holds the value of the team edge.
Team *User
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges PetEdges `json:"edges"`
owner_id *string
team_id *string
}
// PetEdges holds the relations/edges for other nodes in the graph.
type PetEdges struct {
// Team holds the value of the team edge.
Team *User
// Owner holds the value of the owner edge.
Owner *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Pet) scanValues() []interface{} {
return []interface{}{

View File

@@ -22,10 +22,13 @@ type Spec struct {
ID string `json:"id,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the SpecQuery when eager-loading is set.
Edges struct {
// Card holds the value of the card edge.
Card []*Card
} `json:"edges"`
Edges SpecEdges `json:"edges"`
}
// SpecEdges holds the relations/edges for other nodes in the graph.
type SpecEdges struct {
// Card holds the value of the card edge.
Card []*Card
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -38,35 +38,38 @@ type User struct {
Role user.Role `json:"role,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Card holds the value of the card edge.
Card *Card
// Pets holds the value of the pets edge.
Pets []*Pet
// Files holds the value of the files edge.
Files []*File
// Groups holds the value of the groups edge.
Groups []*Group
// Friends holds the value of the friends edge.
Friends []*User
// Followers holds the value of the followers edge.
Followers []*User
// Following holds the value of the following edge.
Following []*User
// Team holds the value of the team edge.
Team *Pet
// Spouse holds the value of the spouse edge.
Spouse *User
// Children holds the value of the children edge.
Children []*User
// Parent holds the value of the parent edge.
Parent *User
} `json:"edges"`
Edges UserEdges `json:"edges"`
group_blocked_id *string
user_spouse_id *string
parent_id *string
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Card holds the value of the card edge.
Card *Card
// Pets holds the value of the pets edge.
Pets []*Pet
// Files holds the value of the files edge.
Files []*File
// Groups holds the value of the groups edge.
Groups []*Group
// Friends holds the value of the friends edge.
Friends []*User
// Followers holds the value of the followers edge.
Followers []*User
// Following holds the value of the following edge.
Following []*User
// Team holds the value of the team edge.
Team *Pet
// Spouse holds the value of the spouse edge.
Spouse *User
// Children holds the value of the children edge.
Children []*User
// Parent holds the value of the parent edge.
Parent *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*User) scanValues() []interface{} {
return []interface{}{

View File

@@ -30,17 +30,20 @@ type Card struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CardQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
// Spec holds the value of the spec edge.
Spec []*Spec
} `json:"edges"`
Edges CardEdges `json:"edges"`
// StaticField defined by templates.
StaticField string `json:"boring,omitempty"`
}
// CardEdges holds the relations/edges for other nodes in the graph.
type CardEdges struct {
// Owner holds the value of the owner edge.
Owner *User
// Spec holds the value of the spec edge.
Spec []*Spec
}
// FromResponse scans the gremlin response data into Card.
func (c *Card) FromResponse(res *gremlin.Response) error {
vmap, err := res.ReadValueMap()

View File

@@ -29,12 +29,15 @@ type File struct {
Group string `json:"group,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the FileQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
// Type holds the value of the type edge.
Type *FileType
} `json:"edges"`
Edges FileEdges `json:"edges"`
}
// FileEdges holds the relations/edges for other nodes in the graph.
type FileEdges struct {
// Owner holds the value of the owner edge.
Owner *User
// Type holds the value of the type edge.
Type *FileType
}
// FromResponse scans the gremlin response data into File.

View File

@@ -23,10 +23,13 @@ type FileType struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the FileTypeQuery when eager-loading is set.
Edges struct {
// Files holds the value of the files edge.
Files []*File
} `json:"edges"`
Edges FileTypeEdges `json:"edges"`
}
// FileTypeEdges holds the relations/edges for other nodes in the graph.
type FileTypeEdges struct {
// Files holds the value of the files edge.
Files []*File
}
// FromResponse scans the gremlin response data into FileType.

View File

@@ -32,16 +32,19 @@ type Group struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupQuery when eager-loading is set.
Edges struct {
// Files holds the value of the files edge.
Files []*File
// Blocked holds the value of the blocked edge.
Blocked []*User
// Users holds the value of the users edge.
Users []*User
// Info holds the value of the info edge.
Info *GroupInfo
} `json:"edges"`
Edges GroupEdges `json:"edges"`
}
// GroupEdges holds the relations/edges for other nodes in the graph.
type GroupEdges struct {
// Files holds the value of the files edge.
Files []*File
// Blocked holds the value of the blocked edge.
Blocked []*User
// Users holds the value of the users edge.
Users []*User
// Info holds the value of the info edge.
Info *GroupInfo
}
// FromResponse scans the gremlin response data into Group.

View File

@@ -25,10 +25,13 @@ type GroupInfo struct {
MaxUsers int `json:"max_users,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupInfoQuery when eager-loading is set.
Edges struct {
// Groups holds the value of the groups edge.
Groups []*Group
} `json:"edges"`
Edges GroupInfoEdges `json:"edges"`
}
// GroupInfoEdges holds the relations/edges for other nodes in the graph.
type GroupInfoEdges struct {
// Groups holds the value of the groups edge.
Groups []*Group
}
// FromResponse scans the gremlin response data into GroupInfo.

View File

@@ -23,12 +23,15 @@ type Node struct {
Value int `json:"value,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the NodeQuery when eager-loading is set.
Edges struct {
// Prev holds the value of the prev edge.
Prev *Node `gqlgen:prev`
// Next holds the value of the next edge.
Next *Node `gqlgen:next`
} `json:"edges"`
Edges NodeEdges `json:"edges"`
}
// NodeEdges holds the relations/edges for other nodes in the graph.
type NodeEdges struct {
// Prev holds the value of the prev edge.
Prev *Node `gqlgen:prev`
// Next holds the value of the next edge.
Next *Node `gqlgen:next`
}
// FromResponse scans the gremlin response data into Node.

View File

@@ -23,12 +23,15 @@ type Pet struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PetQuery when eager-loading is set.
Edges struct {
// Team holds the value of the team edge.
Team *User
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges PetEdges `json:"edges"`
}
// PetEdges holds the relations/edges for other nodes in the graph.
type PetEdges struct {
// Team holds the value of the team edge.
Team *User
// Owner holds the value of the owner edge.
Owner *User
}
// FromResponse scans the gremlin response data into Pet.

View File

@@ -21,10 +21,13 @@ type Spec struct {
ID string `json:"id,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the SpecQuery when eager-loading is set.
Edges struct {
// Card holds the value of the card edge.
Card []*Card
} `json:"edges"`
Edges SpecEdges `json:"edges"`
}
// SpecEdges holds the relations/edges for other nodes in the graph.
type SpecEdges struct {
// Card holds the value of the card edge.
Card []*Card
}
// FromResponse scans the gremlin response data into Spec.

View File

@@ -38,30 +38,33 @@ type User struct {
Role user.Role `json:"role,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Card holds the value of the card edge.
Card *Card
// Pets holds the value of the pets edge.
Pets []*Pet
// Files holds the value of the files edge.
Files []*File
// Groups holds the value of the groups edge.
Groups []*Group
// Friends holds the value of the friends edge.
Friends []*User
// Followers holds the value of the followers edge.
Followers []*User
// Following holds the value of the following edge.
Following []*User
// Team holds the value of the team edge.
Team *Pet
// Spouse holds the value of the spouse edge.
Spouse *User
// Children holds the value of the children edge.
Children []*User
// Parent holds the value of the parent edge.
Parent *User
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Card holds the value of the card edge.
Card *Card
// Pets holds the value of the pets edge.
Pets []*Pet
// Files holds the value of the files edge.
Files []*File
// Groups holds the value of the groups edge.
Groups []*Group
// Friends holds the value of the friends edge.
Friends []*User
// Followers holds the value of the followers edge.
Followers []*User
// Following holds the value of the following edge.
Following []*User
// Team holds the value of the team edge.
Team *Pet
// Spouse holds the value of the spouse edge.
Spouse *User
// Children holds the value of the children edge.
Children []*User
// Parent holds the value of the parent edge.
Parent *User
}
// FromResponse scans the gremlin response data into User.

View File

@@ -23,17 +23,20 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Spouse holds the value of the spouse edge.
Spouse *User
// Followers holds the value of the followers edge.
Followers []*User
// Following holds the value of the following edge.
Following []*User
} `json:"edges"`
Edges UserEdges `json:"edges"`
user_spouse_id *uint64
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Spouse holds the value of the spouse edge.
Spouse *User
// Followers holds the value of the followers edge.
Followers []*User
// Following holds the value of the following edge.
Following []*User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*User) scanValues() []interface{} {
return []interface{}{

View File

@@ -21,13 +21,16 @@ type Car struct {
ID int `json:"id,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CarQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges CarEdges `json:"edges"`
owner_id *int
}
// CarEdges holds the relations/edges for other nodes in the graph.
type CarEdges struct {
// Owner holds the value of the owner edge.
Owner *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Car) scanValues() []interface{} {
return []interface{}{

View File

@@ -35,20 +35,23 @@ type User struct {
State user.State `json:"state,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Parent holds the value of the parent edge.
Parent *User
// Children holds the value of the children edge.
Children []*User
// Spouse holds the value of the spouse edge.
Spouse *User
// Car holds the value of the car edge.
Car *Car
} `json:"edges"`
Edges UserEdges `json:"edges"`
parent_id *int
user_spouse_id *int
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Parent holds the value of the parent edge.
Parent *User
// Children holds the value of the children edge.
Children []*User
// Spouse holds the value of the spouse edge.
Spouse *User
// Car holds the value of the car edge.
Car *Car
}
// scanValues returns the types for scanning values from sql.Rows.
func (*User) scanValues() []interface{} {
return []interface{}{

View File

@@ -21,13 +21,16 @@ type Car struct {
ID int `json:"id,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CarQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges CarEdges `json:"edges"`
owner_id *int
}
// CarEdges holds the relations/edges for other nodes in the graph.
type CarEdges struct {
// Owner holds the value of the owner edge.
Owner *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Car) scanValues() []interface{} {
return []interface{}{

View File

@@ -39,10 +39,13 @@ type User struct {
State user.State `json:"state,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Car holds the value of the car edge.
Car []*Car
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Car holds the value of the car edge.
Car []*Car
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -26,13 +26,16 @@ type Pet struct {
LicensedAt *time.Time `json:"licensed_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PetQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges PetEdges `json:"edges"`
owner_id *int
}
// PetEdges holds the relations/edges for other nodes in the graph.
type PetEdges struct {
// Owner holds the value of the owner edge.
Owner *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Pet) scanValues() []interface{} {
return []interface{}{

View File

@@ -23,12 +23,15 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Pets holds the value of the pets edge.
Pets []*Pet
// Friends holds the value of the friends edge.
Friends []*User
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Pets holds the value of the pets edge.
Pets []*Pet
// Friends holds the value of the friends edge.
Friends []*User
}
// scanValues returns the types for scanning values from sql.Rows.