MCPcopy Index your code
hub / github.com/cli/cli / GraphQLMutationMatcher

Function GraphQLMutationMatcher

pkg/httpmock/stub.go:64–89  ·  view source on GitHub ↗
(q string, cb func(map[string]interface{}) bool)

Source from the content-addressed store, hash-verified

62}
63
64func GraphQLMutationMatcher(q string, cb func(map[string]interface{}) bool) Matcher {
65 re := regexp.MustCompile(q)
66
67 return func(req *http.Request) bool {
68 if !strings.EqualFold(req.Method, "POST") {
69 return false
70 }
71 if req.URL.Path != "/graphql" && req.URL.Path != "/api/graphql" {
72 return false
73 }
74
75 var bodyData struct {
76 Query string
77 Variables struct {
78 Input map[string]interface{}
79 }
80 }
81 _ = decodeJSONBody(req, &bodyData)
82
83 if re.MatchString(bodyData.Query) {
84 return cb(bodyData.Variables.Input)
85 }
86
87 return false
88 }
89}
90
91func QueryMatcher(method string, path string, query url.Values) Matcher {
92 return func(req *http.Request) bool {

Callers 6

TestCreateFunction · 0.92
TestEditDiscussionLabelsFunction · 0.92
TestAddCommentFunction · 0.92
TestUpdateCommentFunction · 0.92
Test_createRunFunction · 0.92
Test_editRunFunction · 0.92

Calls 1

decodeJSONBodyFunction · 0.85

Tested by 6

TestCreateFunction · 0.74
TestEditDiscussionLabelsFunction · 0.74
TestAddCommentFunction · 0.74
TestUpdateCommentFunction · 0.74
Test_createRunFunction · 0.74
Test_editRunFunction · 0.74