MCPcopy
hub / github.com/dgraph-io/dgraph / convertScalarToString

Function convertScalarToString

graphql/resolve/query.go:241–260  ·  view source on GitHub ↗

converts scalar values received from GraphQL arguments to go string If it is a scalar only possible cases are: string, bool, int64, float64 and nil.

(val interface{})

Source from the content-addressed store, hash-verified

239// converts scalar values received from GraphQL arguments to go string
240// If it is a scalar only possible cases are: string, bool, int64, float64 and nil.
241func convertScalarToString(val interface{}) (string, error) {
242 var str string
243 switch v := val.(type) {
244 case string:
245 str = v
246 case bool:
247 str = strconv.FormatBool(v)
248 case int64:
249 str = strconv.FormatInt(v, 10)
250 case float64:
251 str = strconv.FormatFloat(v, 'f', -1, 64)
252 case json.Number:
253 str = v.String()
254 case nil:
255 str = ""
256 default:
257 return "", errNotScalar
258 }
259 return str, nil
260}

Callers 1

rewriteAndExecuteMethod · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected