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

Method scalar

script/ghmock/gqlscaffold.go:199–236  ·  view source on GitHub ↗

scalar makes a placeholder for a scalar field. Strings hold the field's name, so gh's output shows where each value came from.

(scalar, field, parent string)

Source from the content-addressed store, hash-verified

197// scalar makes a placeholder for a scalar field. Strings hold the field's
198// name, so gh's output shows where each value came from.
199func (s *gqlScaffolder) scalar(scalar, field, parent string) any {
200 switch scalar {
201 case "ID":
202 s.ids[parent]++
203 return fmt.Sprintf("%s_%d", parent, s.ids[parent])
204 case "Int", "Float":
205 return 1
206 case "BigInt":
207 return "1"
208 case "Boolean":
209 // Fields such as hasIssuesEnabled turn a feature on. gh issue list
210 // and gh issue create stop when hasIssuesEnabled is false.
211 return strings.HasPrefix(field, "has") && strings.HasSuffix(field, "Enabled")
212 case "DateTime", "GitTimestamp":
213 return placeholderTime
214 case "PreciseDateTime":
215 return "2026-01-01T00:00:00.000Z"
216 case "Date":
217 return placeholderDate
218 case "URI":
219 return placeholderURL
220 case "GitObjectID":
221 return placeholderOID
222 case "GitRefname":
223 return "refs/heads/main"
224 case "GitSSHRemote":
225 return "git@github.com:" + placeholderRepo + ".git"
226 case "HTML":
227 return "<p>" + field + "</p>"
228 case "Base64String":
229 return base64.StdEncoding.EncodeToString([]byte(field))
230 }
231 if field == "nameWithOwner" {
232 // gh splits this at the slash.
233 return placeholderRepo
234 }
235 return field
236}
237
238// concreteType picks the object type to build for a field whose type is an
239// interface or union: the type in __typename, else the first fragment's type,

Callers 1

generateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected