1 Star 0 Fork 0

idsutong/gqlgen

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
directive.go 619 Bytes
一键复制 编辑 原始数据 按行查看 历史
Adam Scarr 提交于 2018-08-01 16:16 . Add directive args
package codegen
import (
"fmt"
"strconv"
"strings"
)
type Directive struct {
Name string
Args []FieldArgument
}
func (d *Directive) CallArgs() string {
args := []string{"ctx", "n"}
for _, arg := range d.Args {
args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+arg.Signature()+")")
}
return strings.Join(args, ", ")
}
func (d *Directive) Declaration() string {
res := ucFirst(d.Name) + " func(ctx context.Context, next graphql.Resolver"
for _, arg := range d.Args {
res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature())
}
res += ") (res interface{}, err error)"
return res
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/idsutong/gqlgen.git
git@gitee.com:idsutong/gqlgen.git
idsutong
gqlgen
gqlgen
v0.4.4

搜索帮助