Skip to content

Commit 91c5cfe

Browse files
committed
feat: add comments to relay connection edges and query fields
1 parent 26c4599 commit 91c5cfe

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

entgql/internal/todoglobalid/ent.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,9 @@ type User implements Node {
12551255
username: UUID!
12561256
requiredMetadata: Map!
12571257
metadata: Map
1258+
"""
1259+
The groups of the user
1260+
"""
12581261
groups(
12591262
"""
12601263
Returns the elements in the list that come after the specified cursor.

entgql/internal/todoglobalid/schema/group.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ func (Group) Edges() []ent.Edge {
4949
func (Group) Annotations() []schema.Annotation {
5050
return []schema.Annotation{
5151
entgql.RelayConnection(),
52-
entgql.QueryField(),
52+
entgql.QueryField().
53+
Description("The groups of the user"),
5354
entgql.Directives(
5455
annotation.HasPermissions([]string{"ADMIN", "MODERATOR"}),
5556
),

entgql/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (e *schemaGenerator) buildTypes(g *gen.Graph, s *ast.Schema) error {
219219
_, hasOrderBy := s.Types[names.Order]
220220
hasWhereInput := e.genWhereInput && !ant.Skip.Is(SkipWhereInput)
221221

222-
def := names.ConnectionField(name, hasOrderBy, ant.MultiOrder, hasWhereInput)
222+
def := names.ConnectionField(name, ant.Description, hasOrderBy, ant.MultiOrder, hasWhereInput)
223223
def.Description = ant.QueryField.Description
224224
def.Directives = e.buildDirectives(ant.QueryField.Directives)
225225
queryFields = append(queryFields, def)
@@ -456,7 +456,7 @@ func (e *schemaGenerator) buildEdge(node *gen.Type, edge *gen.Edge, edgeAnt *Ann
456456
}
457457

458458
fieldDef = paginationNames(gqlType).
459-
ConnectionField(name, len(orderFields) > 0, ant.MultiOrder,
459+
ConnectionField(name, edge.Comment(), len(orderFields) > 0, ant.MultiOrder,
460460
e.genWhereInput && !edgeAnt.Skip.Is(SkipWhereInput) && !ant.Skip.Is(SkipWhereInput),
461461
)
462462
default:

entgql/template.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,11 @@ func (p *PaginationNames) OrderInputDef() *ast.Definition {
632632
}
633633
}
634634

635-
func (p *PaginationNames) ConnectionField(name string, hasOrderBy, multiOrder, hasWhereInput bool) *ast.FieldDefinition {
635+
func (p *PaginationNames) ConnectionField(name, description string, hasOrderBy, multiOrder, hasWhereInput bool) *ast.FieldDefinition {
636636
def := &ast.FieldDefinition{
637-
Name: name,
638-
Type: ast.NonNullNamedType(p.Connection, nil),
637+
Name: name,
638+
Description: description,
639+
Type: ast.NonNullNamedType(p.Connection, nil),
639640
Arguments: ast.ArgumentDefinitionList{
640641
{
641642
Name: "after",

entgql/testdata/schema_relay.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,9 @@ type User implements Node {
12091209
username: UUID!
12101210
requiredMetadata: Map!
12111211
metadata: Map
1212+
"""
1213+
The groups of the user
1214+
"""
12121215
groups(
12131216
"""
12141217
Returns the elements in the list that come after the specified cursor.

entgql/testdata/schema_relay_output.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,9 @@ type User implements Node {
12091209
username: UUID!
12101210
requiredMetadata: Map!
12111211
metadata: Map
1212+
"""
1213+
The groups of the user
1214+
"""
12121215
groups(
12131216
"""
12141217
Returns the elements in the list that come after the specified cursor.

0 commit comments

Comments
 (0)