diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e5e215a..4d96cb2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,10 +15,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + uses: actions/checkout@v5 + - uses: actions/setup-go@v6 with: - go-version: "1.20" + go-version: "1.22" - name: Install dependencies run: | go get -t -v ./... diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 562e186..5bfd6ff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,10 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + uses: actions/checkout@v5 + - uses: actions/setup-go@v6 with: - go-version: "1.20" + go-version: "1.22" - name: Install dependencies run: | go get -t -v ./... diff --git a/.golangci.yml b/.golangci.yml index 93dc46d..837d0b5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,6 +14,8 @@ linters: - mnd - recvcheck - wsl + - wsl_v5 + - godoclint - makezero - godox - gocognit @@ -22,6 +24,7 @@ linters: - forcetypeassert - containedctx - maintidx + - noinlineerr settings: exhaustive: # Program elements to check for exhaustiveness. diff --git a/graphql.go b/graphql.go index fabb19e..5a3b052 100644 --- a/graphql.go +++ b/graphql.go @@ -2,7 +2,6 @@ package graphql import ( "bytes" - "compress/gzip" "context" "encoding/json" "errors" @@ -214,7 +213,6 @@ func (c *Client) doHttpRequest(ctx context.Context, body io.ReadSeeker) *rawGrap } request.Header.Add("Content-Type", "application/json") - request.Header.Add("Accept-Encoding", "gzip") if c.requestModifier != nil { c.requestModifier(request) @@ -338,28 +336,6 @@ func (c *Client) decodeRawGraphQLResponse( ) *rawGraphQLResult { var r io.Reader = resp.Body - if resp.Header.Get("Content-Encoding") == "gzip" { - gr, err := gzip.NewReader(r) - if err != nil { - return &rawGraphQLResult{ - request: req, - requestBody: reqBody, - Errors: Errors{ - newError( - ErrJsonDecode, - fmt.Errorf("problem trying to create gzip reader: %w", err), - ), - }, - } - } - - defer func() { - _ = gr.Close() - }() - - r = gr - } - // copy the response reader for debugging var respReader *bytes.Reader @@ -760,7 +736,9 @@ const ( queryOperation operationType = iota mutationOperation // subscriptionOperation // Unused. +) +const ( ErrRequestError = "request_error" ErrJsonEncode = "json_encode_error" ErrJsonDecode = "json_decode_error" diff --git a/graphql_test.go b/graphql_test.go index 08693f0..0909341 100644 --- a/graphql_test.go +++ b/graphql_test.go @@ -985,10 +985,10 @@ func TestClient_Query_Compression(t *testing.T) { gw.Close() }) - client := graphql.NewClient( - "/graphql", - &http.Client{Transport: localRoundTripper{handler: mux}}, - ) + server := httptest.NewServer(mux) + defer server.Close() + + client := graphql.NewClient(server.URL+"/graphql", http.DefaultClient) var q struct { User struct {