Skip to content
Merged
Show file tree
Hide file tree
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: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ linters:
- mnd
- recvcheck
- wsl
- wsl_v5
- godoclint
- makezero
- godox
- gocognit
Expand All @@ -22,6 +24,7 @@ linters:
- forcetypeassert
- containedctx
- maintidx
- noinlineerr
settings:
exhaustive:
# Program elements to check for exhaustiveness.
Expand Down
26 changes: 2 additions & 24 deletions graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package graphql

import (
"bytes"
"compress/gzip"
"context"
"encoding/json"
"errors"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -760,7 +736,9 @@ const (
queryOperation operationType = iota
mutationOperation
// subscriptionOperation // Unused.
)

const (
ErrRequestError = "request_error"
ErrJsonEncode = "json_encode_error"
ErrJsonDecode = "json_decode_error"
Expand Down
8 changes: 4 additions & 4 deletions graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down