Skip to content

Commit

Permalink
Merge pull request #830 from CircleCI-Public/ensure-we-use-token-graphql
Browse files Browse the repository at this point in the history
fix: make sure we're using token in every graphql request
  • Loading branch information
rlegan authored Jan 24, 2023
2 parents 99feff3 + a8d8a2e commit 35d81d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ func ConfigQueryLegacy(cl *graphql.Client, configPath string, orgSlug string, pa
fieldAddendums)

request := graphql.NewRequest(query)
request.SetToken(cl.Token)
request.Var("config", config)

if values != nil {
Expand All @@ -560,8 +561,6 @@ func ConfigQueryLegacy(cl *graphql.Client, configPath string, orgSlug string, pa
request.Var("orgSlug", orgSlug)
}

request.SetToken(cl.Token)

err = cl.Run(request, &response)
if err != nil {
return nil, errors.Wrap(err, "Unable to validate config")
Expand Down Expand Up @@ -603,6 +602,7 @@ func ConfigQuery(cl *graphql.Client, configPath string, orgId string, params pip
fieldAddendums)

request := graphql.NewRequest(query)
request.SetToken(cl.Token)
request.Var("config", config)

if values != nil {
Expand All @@ -619,7 +619,6 @@ func ConfigQuery(cl *graphql.Client, configPath string, orgId string, params pip
if orgId != "" {
request.Var("orgId", orgId)
}
request.SetToken(cl.Token)

err = cl.Run(request, &response)
if err != nil {
Expand Down Expand Up @@ -1634,6 +1633,7 @@ query namespaceOrbs ($namespace: String, $after: String!) {

for {
request := graphql.NewRequest(query)
request.SetToken(cl.Token)
request.Var("after", currentCursor)
request.Var("namespace", namespace)

Expand Down Expand Up @@ -1813,7 +1813,7 @@ func OrbCategoryID(cl *graphql.Client, name string) (*OrbCategoryIDResponse, err
}`

request := graphql.NewRequest(query)

request.SetToken(cl.Token)
request.Var("name", name)

err := cl.Run(request, &response)
Expand Down Expand Up @@ -1917,6 +1917,7 @@ func ListOrbCategories(cl *graphql.Client) (*OrbCategoriesForListing, error) {

for {
request := graphql.NewRequest(query)
request.SetToken(cl.Token)
request.Var("after", currentCursor)

err := cl.Run(request, &result)
Expand Down
4 changes: 4 additions & 0 deletions cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ var _ = Describe("Config", func() {
}`

r := graphql.NewRequest(query)
r.SetToken(token)
r.Variables["config"] = config
r.Variables["pipelineValues"] = pipeline.PrepareForGraphQL(pipeline.LocalPipelineValues())

Expand Down Expand Up @@ -253,6 +254,7 @@ var _ = Describe("Config", func() {
}`

r := graphql.NewRequest(query)
r.SetToken(token)
r.Variables["config"] = config
r.Variables["pipelineValues"] = pipeline.PrepareForGraphQL(pipeline.LocalPipelineValues())

Expand Down Expand Up @@ -317,6 +319,7 @@ var _ = Describe("Config", func() {
}`

r := graphql.NewRequest(query)
r.SetToken(token)
r.Variables["config"] = config
r.Variables["orgId"] = orgId
r.Variables["pipelineValues"] = pipeline.PrepareForGraphQL(pipeline.LocalPipelineValues())
Expand Down Expand Up @@ -379,6 +382,7 @@ var _ = Describe("Config", func() {
}`

r := graphql.NewRequest(query)
r.SetToken(token)
r.Variables["config"] = config
r.Variables["orgSlug"] = orgSlug
r.Variables["pipelineValues"] = pipeline.PrepareForGraphQL(pipeline.LocalPipelineValues())
Expand Down

0 comments on commit 35d81d4

Please sign in to comment.