forked from icco/graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels_gen.go
More file actions
88 lines (73 loc) · 1.74 KB
/
models_gen.go
File metadata and controls
88 lines (73 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package graphql
import (
fmt "fmt"
io "io"
strconv "strconv"
time "time"
)
// Comment is an undefined type reserved for the future.
type Comment struct {
ID string `json:"id"`
}
// A link is a link I have save on pinboard or a link in a post.
type Link struct {
ID string `json:"id"`
Title string `json:"title"`
URI string `json:"uri"`
Created time.Time `json:"created"`
Description string `json:"description"`
Screenshot string `json:"screenshot"`
Tags []string `json:"tags"`
}
type NewLink struct {
Title string `json:"title"`
URI string `json:"uri"`
Description string `json:"description"`
Tags []*string `json:"tags"`
Created time.Time `json:"created"`
}
type NewPost struct {
Content string `json:"content"`
Title string `json:"title"`
Datetime time.Time `json:"datetime"`
Draft bool `json:"draft"`
}
type NewStat struct {
Key string `json:"key"`
Value string `json:"value"`
}
// A stat is a key value pair of two interesting strings.
type Stat struct {
Key string `json:"key"`
Value string `json:"value"`
}
type Role string
const (
RoleAdmin Role = "admin"
RoleNormal Role = "normal"
)
func (e Role) IsValid() bool {
switch e {
case RoleAdmin, RoleNormal:
return true
}
return false
}
func (e Role) String() string {
return string(e)
}
func (e *Role) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = Role(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid Role", str)
}
return nil
}
func (e Role) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}