forked from 99designs/gqlgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
104 lines (76 loc) · 1.68 KB
/
models.go
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package followschema
import (
"context"
"fmt"
"io"
)
type ForcedResolver struct {
Field Circle
}
type ModelMethods struct{}
func (m ModelMethods) NoContext() bool {
return true
}
func (m ModelMethods) WithContext(_ context.Context) bool {
return true
}
type Errors struct{}
type Error struct {
ID string
}
func (Error) ErrorOnRequiredField() (string, error) {
return "", fmt.Errorf("boom")
}
func (Error) ErrorOnNonRequiredField() (string, error) {
return "", fmt.Errorf("boom")
}
func (Error) NilOnRequiredField() *string {
return nil
}
type EmbeddedPointerModel struct {
*EmbeddedPointer
ID string
}
type EmbeddedPointer struct {
Title string
}
type MarshalPanic string
func (m *MarshalPanic) UnmarshalGQL(v interface{}) error {
panic("BOOM")
}
func (m MarshalPanic) MarshalGQL(w io.Writer) {
panic("BOOM")
}
type Panics struct{}
func (p *Panics) FieldFuncMarshal(ctx context.Context, u []MarshalPanic) []MarshalPanic {
return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")}
}
type Autobind struct {
Int int
Int32 int32
Int64 int64
IdStr string
IdInt int
}
type OverlappingFields struct {
Foo int
NewFoo int
}
type ObjectDirectivesWithCustomGoModel struct {
NullableText string // not *string, but schema is `String @toNull` type.
}
type FallbackToStringEncoding string
const (
FallbackToStringEncodingA FallbackToStringEncoding = "A"
FallbackToStringEncodingB FallbackToStringEncoding = "B"
FallbackToStringEncodingC FallbackToStringEncoding = "C"
)
type Primitive int
func (p Primitive) Squared() int {
return int(p) * int(p)
}
type PrimitiveString string
func (s PrimitiveString) Doubled() string {
return string(s) + string(s)
}
type Bytes []byte