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

Function parseGraphQL

script/ghmock/request.go:72–87  ·  view source on GitHub ↗
(body []byte)

Source from the content-addressed store, hash-verified

70}
71
72func parseGraphQL(body []byte) *graphQLRequest {
73 var payload struct {
74 Query string `json:"query"`
75 Variables json.RawMessage `json:"variables"`
76 OperationName string `json:"operationName"`
77 }
78 if err := json.Unmarshal(body, &payload); err != nil || payload.Query == "" {
79 return nil
80 }
81 vars := payload.Variables
82 if trimmed := bytes.TrimSpace(vars); len(trimmed) == 0 || string(trimmed) == "null" {
83 vars = nil
84 }
85 kind, name := operationName(payload.Query, payload.OperationName)
86 return &graphQLRequest{Kind: kind, Operation: name, Query: payload.Query, Variables: vars}
87}
88
89// operationName resolves the requested operation, or the document's sole
90// operation when no name is supplied. Invalid selections retain the supplied

Callers 1

requestNameFunction · 0.85

Calls 1

operationNameFunction · 0.85

Tested by

no test coverage detected