Skip to content

Commit

Permalink
Use current pattern for making requests with wrapped graphql client
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Aug 31, 2018
1 parent 15d37ff commit 67a7692
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/CircleCI-Public/circleci-cli/client"
"github.com/CircleCI-Public/circleci-cli/logger"
"github.com/Masterminds/semver"
"github.com/machinebox/graphql"
"github.com/pkg/errors"
"github.com/spf13/viper"
yaml "gopkg.in/yaml.v2"
Expand Down Expand Up @@ -753,7 +752,7 @@ func ListNamespaceOrbs(ctx context.Context, logger *logger.Logger, namespace str
}
}

request := graphql.NewRequest(`
query := `
query namespaceOrbs ($namespace: String, $after: String!) {
registryNamespace(name: $namespace) {
name
Expand All @@ -775,22 +774,23 @@ query namespaceOrbs ($namespace: String, $after: String!) {
}
}
}
`)
`

address, err := GraphQLServerAddress(EnvEndpointHost())
if err != nil {
return err
}
client := client.NewClient(address, logger)
graphQLclient := client.NewClient(address, logger)

var result namespaceOrbResponse
currentCursor := ""

for {
request := client.NewAuthorizedRequest(viper.GetString("token"), query)
request.Var("after", currentCursor)
request.Var("namespace", namespace)
err := client.Run(ctx, request, &result)

err := graphQLclient.Run(ctx, request, &result)
if err != nil {
return errors.Wrap(err, "GraphQL query failed")
}
Expand Down

0 comments on commit 67a7692

Please sign in to comment.