Simplify GraphQL mutations whose response we are not interested in
This commit is contained in:
parent
886f5e0e78
commit
db50b54513
3 changed files with 15 additions and 33 deletions
|
|
@ -437,26 +437,22 @@ func mockIssueUpdate(t *testing.T, reg *httpmock.Registry) {
|
|||
reg.Register(
|
||||
httpmock.GraphQL(`mutation IssueUpdate\b`),
|
||||
httpmock.GraphQLMutation(`
|
||||
{ "data": { "updateIssue": { "issue": {
|
||||
"id": "123"
|
||||
} } } }`,
|
||||
{ "data": { "updateIssue": { "__typename": "" } } }`,
|
||||
func(inputs map[string]interface{}) {}),
|
||||
)
|
||||
}
|
||||
|
||||
func mockIssueUpdateLabels(t *testing.T, reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`mutation AddLabels\b`),
|
||||
httpmock.GraphQL(`mutation LabelAdd\b`),
|
||||
httpmock.GraphQLMutation(`
|
||||
{ "data": { "addLabelsToLabelable": { "labelable": {
|
||||
} } } }`,
|
||||
{ "data": { "addLabelsToLabelable": { "__typename": "" } } }`,
|
||||
func(inputs map[string]interface{}) {}),
|
||||
)
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`mutation RemoveLabels\b`),
|
||||
httpmock.GraphQL(`mutation LabelRemove\b`),
|
||||
httpmock.GraphQLMutation(`
|
||||
{ "data": { "removeLabelsFromLabelable": { "labelable": {
|
||||
} } } }`,
|
||||
{ "data": { "removeLabelsFromLabelable": { "__typename": "" } } }`,
|
||||
func(inputs map[string]interface{}) {}),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -559,17 +559,15 @@ func mockPullRequestReviewersUpdate(t *testing.T, reg *httpmock.Registry) {
|
|||
|
||||
func mockPullRequestUpdateLabels(t *testing.T, reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`mutation AddLabels\b`),
|
||||
httpmock.GraphQL(`mutation LabelAdd\b`),
|
||||
httpmock.GraphQLMutation(`
|
||||
{ "data": { "addLabelsToLabelable": { "labelable": {
|
||||
} } } }`,
|
||||
{ "data": { "addLabelsToLabelable": { "__typename": "" } } }`,
|
||||
func(inputs map[string]interface{}) {}),
|
||||
)
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`mutation RemoveLabels\b`),
|
||||
httpmock.GraphQL(`mutation LabelRemove\b`),
|
||||
httpmock.GraphQLMutation(`
|
||||
{ "data": { "removeLabelsFromLabelable": { "labelable": {
|
||||
} } } }`,
|
||||
{ "data": { "removeLabelsFromLabelable": { "__typename": "" } } }`,
|
||||
func(inputs map[string]interface{}) {}),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,17 +108,13 @@ func addLabels(httpClient *http.Client, id string, repo ghrepo.Interface, labels
|
|||
|
||||
var mutation struct {
|
||||
AddLabelsToLabelable struct {
|
||||
Labelable struct {
|
||||
Labels struct {
|
||||
TotalCount int
|
||||
}
|
||||
}
|
||||
Typename string `graphql:"__typename"`
|
||||
} `graphql:"addLabelsToLabelable(input: $input)"`
|
||||
}
|
||||
|
||||
variables := map[string]interface{}{"input": params}
|
||||
gql := graphql.NewClient(ghinstance.GraphQLEndpoint(repo.RepoHost()), httpClient)
|
||||
return gql.MutateNamed(context.Background(), "AddLabels", &mutation, variables)
|
||||
return gql.MutateNamed(context.Background(), "LabelAdd", &mutation, variables)
|
||||
}
|
||||
|
||||
func removeLabels(httpClient *http.Client, id string, repo ghrepo.Interface, labels []string) error {
|
||||
|
|
@ -129,25 +125,19 @@ func removeLabels(httpClient *http.Client, id string, repo ghrepo.Interface, lab
|
|||
|
||||
var mutation struct {
|
||||
RemoveLabelsFromLabelable struct {
|
||||
Labelable struct {
|
||||
Labels struct {
|
||||
TotalCount int
|
||||
}
|
||||
}
|
||||
Typename string `graphql:"__typename"`
|
||||
} `graphql:"removeLabelsFromLabelable(input: $input)"`
|
||||
}
|
||||
|
||||
variables := map[string]interface{}{"input": params}
|
||||
gql := graphql.NewClient(ghinstance.GraphQLEndpoint(repo.RepoHost()), httpClient)
|
||||
return gql.MutateNamed(context.Background(), "RemoveLabels", &mutation, variables)
|
||||
return gql.MutateNamed(context.Background(), "LabelRemove", &mutation, variables)
|
||||
}
|
||||
|
||||
func updateIssue(httpClient *http.Client, repo ghrepo.Interface, params githubv4.UpdateIssueInput) error {
|
||||
var mutation struct {
|
||||
UpdateIssue struct {
|
||||
Issue struct {
|
||||
ID string
|
||||
}
|
||||
Typename string `graphql:"__typename"`
|
||||
} `graphql:"updateIssue(input: $input)"`
|
||||
}
|
||||
variables := map[string]interface{}{"input": params}
|
||||
|
|
@ -158,9 +148,7 @@ func updateIssue(httpClient *http.Client, repo ghrepo.Interface, params githubv4
|
|||
func updatePullRequest(httpClient *http.Client, repo ghrepo.Interface, params githubv4.UpdatePullRequestInput) error {
|
||||
var mutation struct {
|
||||
UpdatePullRequest struct {
|
||||
PullRequest struct {
|
||||
ID string
|
||||
}
|
||||
Typename string `graphql:"__typename"`
|
||||
} `graphql:"updatePullRequest(input: $input)"`
|
||||
}
|
||||
variables := map[string]interface{}{"input": params}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue