Skip to content

Commit

Permalink
Add method for generating method name from field
Browse files Browse the repository at this point in the history
  • Loading branch information
creativej committed Jul 23, 2018
1 parent c3c20f8 commit d02d17a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions codegen/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ func (f *Field) IsConcurrent() bool {
return f.IsResolver() && !f.Object.DisableConcurrency
}
func (f *Field) ShortInvocation() string {
if !f.IsResolver() {
methodName := f.MethodName()
if methodName == "" {
return ""
}
shortName := strings.ToUpper(f.GQLName[:1]) + f.GQLName[1:]
res := fmt.Sprintf("%s().%s(ctx", f.Object.GQLType, shortName)
res := fmt.Sprintf("%s(ctx", methodName)
if !f.Object.Root {
res += fmt.Sprintf(", obj")
}
Expand All @@ -82,6 +82,15 @@ func (f *Field) ShortInvocation() string {
res += ")"
return res
}
func (f *Field) MethodName() string {
if !f.IsResolver() {
return ""
}
shortName := strings.ToUpper(f.GQLName[:1]) + f.GQLName[1:]

return fmt.Sprintf("%s().%s", f.Object.GQLType, shortName)
}

func (f *Field) ShortResolverDeclaration() string {
if !f.IsResolver() {
return ""
Expand Down

0 comments on commit d02d17a

Please sign in to comment.