MCPcopy
hub / github.com/cli/cli / GraphQL

Function GraphQL

pkg/httpmock/stub.go:44–62  ·  view source on GitHub ↗
(q string)

Source from the content-addressed store, hash-verified

42}
43
44func GraphQL(q string) Matcher {
45 re := regexp.MustCompile(q)
46
47 return func(req *http.Request) bool {
48 if !strings.EqualFold(req.Method, "POST") {
49 return false
50 }
51 if req.URL.Path != "/graphql" && req.URL.Path != "/api/graphql" {
52 return false
53 }
54
55 var bodyData struct {
56 Query string
57 }
58 _ = decodeJSONBody(req, &bodyData)
59
60 return re.MatchString(bodyData.Query)
61 }
62}
63
64func GraphQLMutationMatcher(q string, cb func(map[string]interface{}) bool) Matcher {
65 re := regexp.MustCompile(q)

Callers 15

TestListFunction · 0.92
TestSearchFunction · 0.92
TestListCategoriesFunction · 0.92
TestGetByNumberFunction · 0.92
TestGetWithCommentsFunction · 0.92
TestGetCommentRepliesFunction · 0.92
TestCreateFunction · 0.92
TestListLabelsFunction · 0.92
TestEditDiscussionLabelsFunction · 0.92
TestUpdateFunction · 0.92
TestAddCommentFunction · 0.92
TestUpdateCommentFunction · 0.92

Calls 1

decodeJSONBodyFunction · 0.85

Tested by 15

TestListFunction · 0.74
TestSearchFunction · 0.74
TestListCategoriesFunction · 0.74
TestGetByNumberFunction · 0.74
TestGetWithCommentsFunction · 0.74
TestGetCommentRepliesFunction · 0.74
TestCreateFunction · 0.74
TestListLabelsFunction · 0.74
TestEditDiscussionLabelsFunction · 0.74
TestUpdateFunction · 0.74
TestAddCommentFunction · 0.74
TestUpdateCommentFunction · 0.74