MCPcopy Index your code
hub / github.com/github/github-mcp-server / queryArguments

Function queryArguments

internal/githubv4mock/query.go:58–78  ·  view source on GitHub ↗

queryArguments constructs a minified arguments string for variables. E.g., map[string]any{"a": Int(123), "b": NewBoolean(true)} -> "$a:Int!$b:Boolean".

(variables map[string]any)

Source from the content-addressed store, hash-verified

56//
57// E.g., map[string]any{"a": Int(123), "b": NewBoolean(true)} -> "$a:Int!$b:Boolean".
58func queryArguments(variables map[string]any) string {
59 // Sort keys in order to produce deterministic output for testing purposes.
60 // TODO: If tests can be made to work with non-deterministic output, then no need to sort.
61 keys := make([]string, 0, len(variables))
62 for k := range variables {
63 keys = append(keys, k)
64 }
65 sort.Strings(keys)
66
67 var buf bytes.Buffer
68 for _, k := range keys {
69 _, _ = io.WriteString(&buf, "$")
70 _, _ = io.WriteString(&buf, k)
71 _, _ = io.WriteString(&buf, ":")
72 writeArgumentType(&buf, reflect.TypeOf(variables[k]), true)
73 // Don't insert a comma here.
74 // Commas in GraphQL are insignificant, and we want minified output.
75 // See https://spec.graphql.org/October2021/#sec-Insignificant-Commas.
76 }
77 return buf.String()
78}
79
80// writeArgumentType writes a minified GraphQL type for t to w.
81// value indicates whether t is a value (required) type or pointer (optional) type.

Callers 2

constructQueryFunction · 0.85
constructMutationFunction · 0.85

Calls 2

writeArgumentTypeFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected