MCPcopy Create free account
hub / github.com/cli/cli / resolve

Method resolve

script/ghmock/introspection.go:191–289  ·  view source on GitHub ↗
(s *gqlScaffolder, field string, args map[string]any)

Source from the content-addressed store, hash-verified

189func (introType) typeName() string { return "__Type" }
190
191func (it introType) resolve(s *gqlScaffolder, field string, args map[string]any) any {
192 t := it.t
193 if t.NonNull || t.Elem != nil {
194 switch field {
195 case "kind":
196 if t.NonNull {
197 return "NON_NULL"
198 }
199 return "LIST"
200 case "ofType":
201 if t.NonNull {
202 inner := *t
203 inner.NonNull = false
204 return introType{&inner}
205 }
206 return introType{t.Elem}
207 }
208 return nil
209 }
210
211 def := s.schema.Types[t.NamedType]
212 if def == nil {
213 return nil
214 }
215 includeDeprecated, _ := args["includeDeprecated"].(bool)
216 switch field {
217 case "kind":
218 return string(def.Kind)
219 case "name":
220 return def.Name
221 case "description":
222 return optional(def.Description)
223 case "specifiedByURL":
224 if d := def.Directives.ForName("specifiedBy"); d != nil {
225 if a := d.Arguments.ForName("url"); a != nil {
226 return a.Value.Raw
227 }
228 }
229 return nil
230 case "fields":
231 if def.Kind != ast.Object && def.Kind != ast.Interface {
232 return nil
233 }
234 list := []introObject{}
235 for _, f := range def.Fields {
236 if strings.HasPrefix(f.Name, "__") || (!includeDeprecated && deprecated(f.Directives)) {
237 continue
238 }
239 list = append(list, introField{f})
240 }
241 return list
242 case "interfaces":
243 if def.Kind != ast.Object && def.Kind != ast.Interface {
244 return nil
245 }
246 list := []introObject{}
247 for _, name := range def.Interfaces {
248 list = append(list, introType{ast.NamedType(name, nil)})

Callers

nothing calls this directly

Calls 2

optionalFunction · 0.85
deprecatedFunction · 0.85

Tested by

no test coverage detected