1 Star 0 Fork 0

idsutong/gqlgen

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
models_gen.go 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
Adam Scarr 提交于 2018-11-26 12:48 +08:00 . Use new import handling code
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package type_system_extension
import (
"fmt"
"io"
"strconv"
)
type Data interface {
IsData()
}
type Node interface {
IsNode()
}
type Todo struct {
ID string `json:"id"`
Text string `json:"text"`
State State `json:"state"`
Verified bool `json:"verified"`
}
func (Todo) IsNode() {}
func (Todo) IsData() {}
type TodoInput struct {
Text string `json:"text"`
}
type State string
const (
StateNotYet State = "NOT_YET"
StateDone State = "DONE"
)
func (e State) IsValid() bool {
switch e {
case StateNotYet, StateDone:
return true
}
return false
}
func (e State) String() string {
return string(e)
}
func (e *State) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = State(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid State", str)
}
return nil
}
func (e State) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/idsutong/gqlgen.git
git@gitee.com:idsutong/gqlgen.git
idsutong
gqlgen
gqlgen
v0.7.2

搜索帮助