Skip to content

Commit

Permalink
chore: Add operation names to dashboard graphql queries for better lo…
Browse files Browse the repository at this point in the history
…gging (#2776)

* chore: Add operation names to dashboard graphql queries for better logging

* test: Fix graphql test endpoint

* test: update golden files
  • Loading branch information
tim775 committed Dec 5, 2023
1 parent ca4bf75 commit 77a3dbc
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/infracost/comment_github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func governanceTestEndpoint(garr governanceAddRunResponse) *httptest.Server {
bodyBytes, _ := io.ReadAll(r.Body)
graphqlQuery := string(bodyBytes)

if strings.Contains(graphqlQuery, "mutation($run: RunInput!, $commentFormat: CommentFormat!)") {
if strings.Contains(graphqlQuery, "mutation AddRun($run: RunInput!, $commentFormat: CommentFormat!)") {
guardrailJson, _ := json.Marshal(garr)

fmt.Fprintf(w, `[{"data": {"addRun":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
policyResourceAllowList:
[
{
"query": "\n\t\tquery {\n\t\t\tpolicyResourceAllowList {\n\t\t\t\tresourceType\n allowed\n\t\t\t}\n\t\t}\n\t",
"query": "\n\t\tquery GetPolicyResourceAllowList{\n\t\t\tpolicyResourceAllowList {\n\t\t\t\tresourceType\n allowed\n\t\t\t}\n\t\t}\n\t",
"variables": {}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
policyResourceAllowList:
[
{
"query": "\n\t\tquery {\n\t\t\tpolicyResourceAllowList {\n\t\t\t\tresourceType\n allowed\n\t\t\t}\n\t\t}\n\t",
"query": "\n\t\tquery GetPolicyResourceAllowList{\n\t\t\tpolicyResourceAllowList {\n\t\t\t\tresourceType\n allowed\n\t\t\t}\n\t\t}\n\t",
"variables": {}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
policyResourceAllowList:
[
{
"query": "\n\t\tquery {\n\t\t\tpolicyResourceAllowList {\n\t\t\t\tresourceType\n allowed\n\t\t\t}\n\t\t}\n\t",
"query": "\n\t\tquery GetPolicyResourceAllowList{\n\t\t\tpolicyResourceAllowList {\n\t\t\t\tresourceType\n allowed\n\t\t\t}\n\t\t}\n\t",
"variables": {}
}
]
Expand Down
2 changes: 1 addition & 1 deletion internal/apiclient/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (c *DashboardAPIClient) AddRun(ctx *config.RunContext, out output.Root, com
}

q := `
mutation($run: RunInput!, $commentFormat: CommentFormat!) {
mutation AddRun($run: RunInput!, $commentFormat: CommentFormat!) {
addRun(run: $run) {
id
shareUrl
Expand Down
4 changes: 2 additions & 2 deletions internal/apiclient/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *PolicyAPIClient) CheckPolicies(ctx *config.RunContext, out output.Root,
}

q := `
query($run: RunInput!, $onlyDiff: Boolean) {
query EvaluatePolicies($run: RunInput!, $onlyDiff: Boolean) {
evaluatePolicies(run: $run, onlyDiff: $onlyDiff) {
tagPolicyResults {
name
Expand Down Expand Up @@ -395,7 +395,7 @@ func (c *PolicyAPIClient) fetchAllowList() error {

func (c *PolicyAPIClient) getPolicyResourceAllowList() (map[string]allowList, error) {
q := `
query {
query GetPolicyResourceAllowList{
policyResourceAllowList {
resourceType
allowed
Expand Down

0 comments on commit 77a3dbc

Please sign in to comment.