Skip to content

Commit

Permalink
Restore multiline resolver doc comments after #3243
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Coffman <[email protected]>
  • Loading branch information
StevenACoffman committed Dec 10, 2024
1 parent 910f51b commit 74babe1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugin/resolvergen/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func (m *Plugin) generatePerSchema(data *codegen.Data) error {
continue
}
structName := templates.LcFirst(o.Name) + templates.UcFirst(data.Config.Resolver.Type)
// TODO(steve): Why do we need to trimLeft "\" here? Some bazel thing?
comment := strings.TrimSpace(strings.TrimLeft(rewriter.GetMethodComment(structName, f.GoFieldName), `\`))
implementation := strings.TrimSpace(rewriter.GetMethodBody(structName, f.GoFieldName))
resolver := Resolver{o, f, rewriter.GetPrevDecl(structName, f.GoFieldName), comment, implementation, nil}
Expand Down
2 changes: 1 addition & 1 deletion plugin/resolvergen/resolver.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

{{ range $resolver := .Resolvers -}}
{{ if $resolver.Comment -}}
// {{ $resolver.Comment }}
{{with $resolver.Comment}}{{.|prefixLines "// "}}{{end}}
{{- else if not $.OmitTemplateComment -}}
// {{ $resolver.Field.GoFieldName }} is the resolver for the {{ $resolver.Field.Name }} field.
{{- end }}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func (r *queryCustomResolverType) Resolver(ctx context.Context) (_ *customresolv
}

// Name is the resolver for the name field.
// This comment is multiline method doc
func (r *resolverCustomResolverType) Name(ctx context.Context, obj *customresolver.Resolver) (string, error) {
// CustomerResolverType.Name implementation
return "", nil
Expand All @@ -26,6 +27,7 @@ func (r *resolverCustomResolverType) Name(ctx context.Context, obj *customresolv
func (r *CustomResolverType) Query() customresolver.QueryResolver { return &queryCustomResolverType{r} }

// Resolver returns customresolver.ResolverResolver implementation.
// This comment is multiline method doc
func (r *CustomResolverType) Resolver() customresolver.ResolverResolver {
return &resolverCustomResolverType{r}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

{{ range $resolver := .Resolvers -}}
{{ if $resolver.Comment -}}
// {{ $resolver.Comment }}
{{with $resolver.Comment}}{{.|prefixLines "// "}}{{end}}
{{- else if not $.OmitTemplateComment -}}
// {{ $resolver.Field.GoFieldName }} is the resolver for the {{ $resolver.Field.Name }} field.
{{- end }}
Expand Down

0 comments on commit 74babe1

Please sign in to comment.