@@ -11,8 +11,7 @@ import (
1111 "strings"
1212
1313 "github.com/cli/cli/v2/internal/ghinstance"
14- "github.com/cli/go-gh"
15- ghAPI "github.com/cli/go-gh/pkg/api"
14+ ghAPI "github.com/cli/go-gh/v2/pkg/api"
1615)
1716
1817const (
@@ -40,11 +39,11 @@ func (c *Client) HTTP() *http.Client {
4039}
4140
4241type GraphQLError struct {
43- ghAPI.GQLError
42+ * ghAPI.GraphQLError
4443}
4544
4645type HTTPError struct {
47- ghAPI.HTTPError
46+ * ghAPI.HTTPError
4847 scopesSuggestion string
4948}
5049
@@ -57,7 +56,7 @@ func (err HTTPError) ScopesSuggestion() string {
5756func (c Client ) GraphQL (hostname string , query string , variables map [string ]interface {}, data interface {}) error {
5857 opts := clientOptions (hostname , c .http .Transport )
5958 opts .Headers [graphqlFeatures ] = features
60- gqlClient , err := gh . GQLClient ( & opts )
59+ gqlClient , err := ghAPI . NewGraphQLClient ( opts )
6160 if err != nil {
6261 return err
6362 }
@@ -69,7 +68,7 @@ func (c Client) GraphQL(hostname string, query string, variables map[string]inte
6968func (c Client ) Mutate (hostname , name string , mutation interface {}, variables map [string ]interface {}) error {
7069 opts := clientOptions (hostname , c .http .Transport )
7170 opts .Headers [graphqlFeatures ] = features
72- gqlClient , err := gh . GQLClient ( & opts )
71+ gqlClient , err := ghAPI . NewGraphQLClient ( opts )
7372 if err != nil {
7473 return err
7574 }
@@ -81,7 +80,7 @@ func (c Client) Mutate(hostname, name string, mutation interface{}, variables ma
8180func (c Client ) Query (hostname , name string , query interface {}, variables map [string ]interface {}) error {
8281 opts := clientOptions (hostname , c .http .Transport )
8382 opts .Headers [graphqlFeatures ] = features
84- gqlClient , err := gh . GQLClient ( & opts )
83+ gqlClient , err := ghAPI . NewGraphQLClient ( opts )
8584 if err != nil {
8685 return err
8786 }
@@ -93,7 +92,7 @@ func (c Client) Query(hostname, name string, query interface{}, variables map[st
9392func (c Client ) QueryWithContext (ctx context.Context , hostname , name string , query interface {}, variables map [string ]interface {}) error {
9493 opts := clientOptions (hostname , c .http .Transport )
9594 opts .Headers [graphqlFeatures ] = features
96- gqlClient , err := gh . GQLClient ( & opts )
95+ gqlClient , err := ghAPI . NewGraphQLClient ( opts )
9796 if err != nil {
9897 return err
9998 }
@@ -103,7 +102,7 @@ func (c Client) QueryWithContext(ctx context.Context, hostname, name string, que
103102// REST performs a REST request and parses the response.
104103func (c Client ) REST (hostname string , method string , p string , body io.Reader , data interface {}) error {
105104 opts := clientOptions (hostname , c .http .Transport )
106- restClient , err := gh . RESTClient ( & opts )
105+ restClient , err := ghAPI . NewRESTClient ( opts )
107106 if err != nil {
108107 return err
109108 }
@@ -112,7 +111,7 @@ func (c Client) REST(hostname string, method string, p string, body io.Reader, d
112111
113112func (c Client ) RESTWithNext (hostname string , method string , p string , body io.Reader , data interface {}) (string , error ) {
114113 opts := clientOptions (hostname , c .http .Transport )
115- restClient , err := gh . RESTClient ( & opts )
114+ restClient , err := ghAPI . NewRESTClient ( opts )
116115 if err != nil {
117116 return "" , err
118117 }
@@ -157,14 +156,14 @@ func HandleHTTPError(resp *http.Response) error {
157156 return handleResponse (ghAPI .HandleHTTPError (resp ))
158157}
159158
160- // handleResponse takes a ghAPI.HTTPError or ghAPI.GQLError and converts it into an
159+ // handleResponse takes a ghAPI.HTTPError or ghAPI.GraphQLError and converts it into an
161160// HTTPError or GraphQLError respectively.
162161func handleResponse (err error ) error {
163162 if err == nil {
164163 return nil
165164 }
166165
167- var restErr ghAPI.HTTPError
166+ var restErr * ghAPI.HTTPError
168167 if errors .As (err , & restErr ) {
169168 return HTTPError {
170169 HTTPError : restErr ,
@@ -175,10 +174,10 @@ func handleResponse(err error) error {
175174 }
176175 }
177176
178- var gqlErr ghAPI.GQLError
177+ var gqlErr * ghAPI.GraphQLError
179178 if errors .As (err , & gqlErr ) {
180179 return GraphQLError {
181- GQLError : gqlErr ,
180+ GraphQLError : gqlErr ,
182181 }
183182 }
184183
0 commit comments