• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

99designs / gqlgen / 12989129605

27 Jan 2025 12:36PM UTC coverage: 73.926% (+0.009%) from 73.917%
12989129605

Pull #3501

github

web-flow
chore(deps-dev): bump vite from 6.0.9 to 6.0.11 in /integration

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.0.9 to 6.0.11.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.0.11/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3501: chore(deps-dev): bump vite from 6.0.9 to 6.0.11 in /integration

8619 of 11659 relevant lines covered (73.93%)

531.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.81
/codegen/object.go
1
package codegen
2

3
import (
4
        "fmt"
5
        "go/types"
6
        "strconv"
7
        "strings"
8
        "unicode"
9

10
        "github.com/vektah/gqlparser/v2/ast"
11
        "golang.org/x/text/cases"
12
        "golang.org/x/text/language"
13

14
        "github.com/99designs/gqlgen/codegen/config"
15
)
16

17
type GoFieldType int
18

19
const (
20
        GoFieldUndefined GoFieldType = iota
21
        GoFieldMethod
22
        GoFieldVariable
23
        GoFieldMap
24
)
25

26
type Object struct {
27
        *ast.Definition
28

29
        Type                     types.Type
30
        ResolverInterface        types.Type
31
        Root                     bool
32
        Fields                   []*Field
33
        Implements               []*ast.Definition
34
        DisableConcurrency       bool
35
        Stream                   bool
36
        Directives               []*Directive
37
        PointersInUnmarshalInput bool
38
}
39

40
func (b *builder) buildObject(typ *ast.Definition) (*Object, error) {
121✔
41
        dirs, err := b.getDirectives(typ.Directives)
121✔
42
        if err != nil {
121✔
43
                return nil, fmt.Errorf("%s: %w", typ.Name, err)
×
44
        }
×
45
        caser := cases.Title(language.English, cases.NoLower)
121✔
46
        obj := &Object{
121✔
47
                Definition:               typ,
121✔
48
                Root:                     b.Config.IsRoot(typ),
121✔
49
                DisableConcurrency:       typ == b.Schema.Mutation,
121✔
50
                Stream:                   typ == b.Schema.Subscription,
121✔
51
                Directives:               dirs,
121✔
52
                PointersInUnmarshalInput: b.Config.ReturnPointersInUnmarshalInput,
121✔
53
                ResolverInterface: types.NewNamed(
121✔
54
                        types.NewTypeName(0, b.Config.Exec.Pkg(), caser.String(typ.Name)+"Resolver", nil),
121✔
55
                        nil,
121✔
56
                        nil,
121✔
57
                ),
121✔
58
        }
121✔
59

121✔
60
        if !obj.Root {
226✔
61
                goObject, err := b.Binder.DefaultUserObject(typ.Name)
105✔
62
                if err != nil {
105✔
63
                        return nil, err
×
64
                }
×
65
                obj.Type = goObject
105✔
66
        }
67

68
        for _, intf := range b.Schema.GetImplements(typ) {
131✔
69
                obj.Implements = append(obj.Implements, b.Schema.Types[intf.Name])
10✔
70
        }
10✔
71

72
        for _, field := range typ.Fields {
654✔
73
                if strings.HasPrefix(field.Name, "__") {
557✔
74
                        continue
24✔
75
                }
76

77
                var f *Field
509✔
78
                f, err = b.buildField(obj, field)
509✔
79
                if err != nil {
510✔
80
                        return nil, err
1✔
81
                }
1✔
82

83
                obj.Fields = append(obj.Fields, f)
508✔
84
        }
85

86
        return obj, nil
120✔
87
}
88

89
func (o *Object) Reference() types.Type {
155✔
90
        if config.IsNilable(o.Type) {
155✔
91
                return o.Type
×
92
        }
×
93
        return types.NewPointer(o.Type)
155✔
94
}
95

96
type Objects []*Object
97

98
func (o *Object) Implementors() string {
31✔
99
        satisfiedBy := strconv.Quote(o.Name)
31✔
100
        for _, s := range o.Implements {
31✔
101
                satisfiedBy += ", " + strconv.Quote(s.Name)
×
102
        }
×
103
        return "[]string{" + satisfiedBy + "}"
31✔
104
}
105

106
func (o *Object) HasResolvers() bool {
150✔
107
        for _, f := range o.Fields {
780✔
108
                if f.IsResolver {
660✔
109
                        return true
30✔
110
                }
30✔
111
        }
112
        return false
120✔
113
}
114

115
func (o *Object) HasUnmarshal() bool {
6✔
116
        if o.IsMap() {
6✔
117
                return false
×
118
        }
×
119
        for i := 0; i < o.Type.(*types.Named).NumMethods(); i++ {
6✔
120
                if o.Type.(*types.Named).Method(i).Name() == "UnmarshalGQL" {
×
121
                        return true
×
122
                }
×
123
        }
124
        return false
6✔
125
}
126

127
func (o *Object) HasDirectives() bool {
×
128
        if len(o.Directives) > 0 {
×
129
                return true
×
130
        }
×
131
        for _, f := range o.Fields {
×
132
                if f.HasDirectives() {
×
133
                        return true
×
134
                }
×
135
        }
136

137
        return false
×
138
}
139

140
func (o *Object) IsConcurrent() bool {
73✔
141
        for _, f := range o.Fields {
404✔
142
                if f.IsConcurrent() {
335✔
143
                        return true
4✔
144
                }
4✔
145
        }
146
        return false
69✔
147
}
148

149
func (o *Object) IsReserved() bool {
62✔
150
        return strings.HasPrefix(o.Definition.Name, "__")
62✔
151
}
62✔
152

153
func (o *Object) IsMap() bool {
15✔
154
        return o.Type == config.MapType
15✔
155
}
15✔
156

157
func (o *Object) Description() string {
×
158
        return o.Definition.Description
×
159
}
×
160

161
func (o *Object) HasField(name string) bool {
×
162
        for _, f := range o.Fields {
×
163
                if f.Name == name {
×
164
                        return true
×
165
                }
×
166
        }
167

168
        return false
×
169
}
170

171
func (os Objects) ByName(name string) *Object {
66✔
172
        for i, o := range os {
576✔
173
                if strings.EqualFold(o.Definition.Name, name) {
560✔
174
                        return os[i]
50✔
175
                }
50✔
176
        }
177
        return nil
16✔
178
}
179

180
func ucFirst(s string) string {
×
181
        if s == "" {
×
182
                return ""
×
183
        }
×
184

185
        r := []rune(s)
×
186
        r[0] = unicode.ToUpper(r[0])
×
187
        return string(r)
×
188
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc