/
field.go
46 lines (42 loc) · 964 Bytes
/
field.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
package parse
import "github.com/Vliro/humus/gen/graphql-go/common"
//Field represents the parsed graphQL field alongside all
//definitions needed for generation.
type Field struct {
//For DB name.
Tag string
//This include omitempty for instance. it is related to the tag.
WrittenTag string
//Name for the field.
Name string
//What type is this field? String etc.
Type string
//Metadata.
flags flags
//like []*string. Used in templates.
TypeLabel string
//did this come from the field or from the interface?
FromInterface bool
Nosave bool
Directives []*common.Directive
Nofield bool
//For templates.
Parent string
IsArray bool
}
func (f *Field) HasDirective(name string) *common.Directive {
for _, v := range f.Directives {
if v.Name.Name == name {
return v
}
}
return nil
}
func (f *Field) IsScalar() bool {
for _, v := range builtins {
if v == f.Type {
return true
}
}
return f.flags&flagEnum > 0
}