Skip to content

Test #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Test #483

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func (c *CfClient) GraphqlAPI(ctx context.Context, query string, variables any,
Body: body,
})
if err != nil {
e,_:=json.Marshal(err)
fmt.Println("GraphQL Error", string(e))
return err
}

Expand All @@ -133,7 +135,7 @@ func (c *CfClient) GraphqlAPI(ctx context.Context, query string, variables any,
if err != nil {
return fmt.Errorf("failed to read response Body: %w", err)
}

fmt.Println("GraphQL Response", string(bytes))
err = json.Unmarshal(bytes, result)
if err != nil {
return fmt.Errorf("failed to unmarshal response Body: %w", err)
Expand Down Expand Up @@ -169,6 +171,7 @@ func (c *CfClient) apiCall(ctx context.Context, baseUrl *url.URL, opt *RequestOp
request.Header.Set("Authorization", c.token)
request.Header.Set("Content-Type", "application/json")
request.Header.Set("origin", c.baseUrl.Host)
fmt.Println("GraphQL Request", method, finalUrl.String(), string(body))

res, err := c.client.Do(request)
if err != nil {
Expand All @@ -182,7 +185,6 @@ func (c *CfClient) apiCall(ctx context.Context, baseUrl *url.URL, opt *RequestOp
if err != nil {
body = fmt.Sprintf("failed to read response Body: %s", err.Error())
}

return nil, &ApiError{
status: res.Status,
statusCode: res.StatusCode,
Expand Down