From d4ebeb8674d793234d8dc488fb7da1356b1ce719 Mon Sep 17 00:00:00 2001 From: miklosbarabas Date: Wed, 3 Sep 2025 17:56:55 +0200 Subject: [PATCH 1/3] feat: upgrade all components to go 1.25 --- .github/workflows/execution.yml | 15 +++++++++------ .github/workflows/v2.yml | 15 +++++++++------ examples/federation/go.mod | 2 +- examples/federation/go.sum | 1 + execution/go.mod | 2 +- go.mod | 2 +- go.work | 4 ++-- v2/go.mod | 2 +- 8 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/execution.yml b/.github/workflows/execution.yml index 099331c44f..6ab72110f2 100644 --- a/.github/workflows/execution.yml +++ b/.github/workflows/execution.yml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go: [ '1.23' ] + go: [ "1.25" ] os: [ubuntu-latest, windows-latest] steps: - name: Set git to use LF @@ -45,18 +45,21 @@ jobs: lint: name: Linters runs-on: ubuntu-latest + strategy: + matrix: + go: [ "1.25" ] steps: - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - name: Set up Go 1.23 - uses: actions/setup-go@v4 + uses: actions/checkout@v4 + - name: Set up Go ${{ matrix.go }} + uses: actions/setup-go@v5 with: - go-version: 1.23 + go-version: ^${{ matrix.go }} - name: Run linters uses: golangci/golangci-lint-action@v8.0.0 with: working-directory: execution - version: v2.3.1 + version: v2.4.0 args: --timeout=3m ci: name: CI Success diff --git a/.github/workflows/v2.yml b/.github/workflows/v2.yml index 30c6723218..0f478d519b 100644 --- a/.github/workflows/v2.yml +++ b/.github/workflows/v2.yml @@ -24,7 +24,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go: [ '1.23' ] + go: [ "1.25" ] os: [ubuntu-latest, windows-latest] steps: - name: Set git to use LF @@ -49,18 +49,21 @@ jobs: lint: name: Linters runs-on: ubuntu-latest + strategy: + matrix: + go: [ "1.25" ] steps: - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - name: Set up Go 1.23 - uses: actions/setup-go@v4 + uses: actions/checkout@v4 + - name: Set up Go ${{ matrix.go }} + uses: actions/setup-go@v5 with: - go-version: 1.23 + go-version: ^${{ matrix.go }} - name: Run linters uses: golangci/golangci-lint-action@v8.0.0 with: working-directory: v2 - version: v2.3.1 + version: v2.4.0 args: --timeout=3m ci: name: CI Success diff --git a/examples/federation/go.mod b/examples/federation/go.mod index 12434c6327..fadb141272 100644 --- a/examples/federation/go.mod +++ b/examples/federation/go.mod @@ -1,6 +1,6 @@ module github.com/wundergraph/graphql-go-tools/examples/federation -go 1.23.0 +go 1.25 require ( github.com/99designs/gqlgen v0.17.45 diff --git a/examples/federation/go.sum b/examples/federation/go.sum index a99e4a2e58..7616011ef2 100644 --- a/examples/federation/go.sum +++ b/examples/federation/go.sum @@ -127,6 +127,7 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sebdah/goldie/v2 v2.7.1 h1:PkBHymaYdtvEkZV7TmyqKxdmn5/Vcj+8TpATWZjnG5E= +github.com/sebdah/goldie/v2 v2.7.1/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= diff --git a/execution/go.mod b/execution/go.mod index 295631bd45..efdcb3cbd4 100644 --- a/execution/go.mod +++ b/execution/go.mod @@ -1,6 +1,6 @@ module github.com/wundergraph/graphql-go-tools/execution -go 1.23.0 +go 1.25 require ( github.com/99designs/gqlgen v0.17.45 diff --git a/go.mod b/go.mod index e27def2dc7..66330ad5ce 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/wundergraph/graphql-go-tools -go 1.23.0 +go 1.25 require ( github.com/99designs/gqlgen v0.17.45 diff --git a/go.work b/go.work index ac5297ceb6..b3c4280860 100644 --- a/go.work +++ b/go.work @@ -1,6 +1,6 @@ -go 1.23.0 +go 1.25 -toolchain go1.23.3 +toolchain go1.25 use ( // v1 diff --git a/v2/go.mod b/v2/go.mod index 9e82186078..8ff4759fb5 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -1,6 +1,6 @@ module github.com/wundergraph/graphql-go-tools/v2 -go 1.23.0 +go 1.25 require ( github.com/99designs/gqlgen v0.17.45 From 38c6a8ecb3576d9ae8f44129a81552d623af0fba Mon Sep 17 00:00:00 2001 From: miklosbarabas Date: Fri, 5 Sep 2025 13:05:11 +0200 Subject: [PATCH 2/3] feat: upgrade all components to go 1.25 - fixed issues found by latest golangci-lint --- pkg/ast/ast_node_kind_test.go | 3 ++- pkg/ast/ast_root_operation_type_definition.go | 1 + .../inject_input_default_values.go | 1 + .../inject_input_default_values_test.go | 3 ++- pkg/astparser/parser_test.go | 4 ++-- pkg/astvalidation/operation_rule_fragments.go | 1 + pkg/astvalidation/rule_populated_type_bodies.go | 1 + .../graphql_subscription_client_test.go | 3 +-- .../graphql_datasource/graphql_tws_handler_test.go | 3 +-- .../graphql_datasource/graphql_ws_handler_test.go | 3 +-- .../datasource/httpclient/httpclient_test.go | 5 ++++- pkg/engine/datasource/httpclient/nethttpclient.go | 4 +++- pkg/execution/datasource_pipeline_test.go | 7 ++++++- pkg/execution/execution_test.go | 14 ++++++++++++-- pkg/execution/planning.go | 4 +++- pkg/federation/schema.go | 2 +- pkg/federation/schema_test.go | 3 ++- pkg/federation/sdlmerge/sdlmerge.go | 6 +++--- pkg/graphql/execution_engine_v2.go | 3 +-- pkg/graphql/execution_engine_v2_norace_test.go | 1 + pkg/http/http.go | 1 + pkg/imports/graphql_file.go | 4 +++- pkg/operationreport/operationreport_test.go | 3 ++- pkg/subscription/websocket/client_test.go | 5 ++++- .../federation_integration_test.go | 5 +++-- .../federationtesting/gateway/datasource_poller.go | 7 ++++++- pkg/testing/federationtesting/gateway/main.go | 3 +-- .../federationtesting/graphql_client_test.go | 7 ++++++- 28 files changed, 75 insertions(+), 32 deletions(-) diff --git a/pkg/ast/ast_node_kind_test.go b/pkg/ast/ast_node_kind_test.go index bbc6326323..2999daf49c 100644 --- a/pkg/ast/ast_node_kind_test.go +++ b/pkg/ast/ast_node_kind_test.go @@ -1,8 +1,9 @@ package ast import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestNodeKindIsAbstractType(t *testing.T) { diff --git a/pkg/ast/ast_root_operation_type_definition.go b/pkg/ast/ast_root_operation_type_definition.go index 0f252dbc82..bd8fff725d 100644 --- a/pkg/ast/ast_root_operation_type_definition.go +++ b/pkg/ast/ast_root_operation_type_definition.go @@ -2,6 +2,7 @@ package ast import ( "bytes" + "github.com/wundergraph/graphql-go-tools/pkg/lexer/position" ) diff --git a/pkg/astnormalization/inject_input_default_values.go b/pkg/astnormalization/inject_input_default_values.go index 3ddb81fb75..ba116aa8a5 100644 --- a/pkg/astnormalization/inject_input_default_values.go +++ b/pkg/astnormalization/inject_input_default_values.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/buger/jsonparser" + "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" ) diff --git a/pkg/astnormalization/inject_input_default_values_test.go b/pkg/astnormalization/inject_input_default_values_test.go index 82e24cfc45..ade8bd7be0 100644 --- a/pkg/astnormalization/inject_input_default_values_test.go +++ b/pkg/astnormalization/inject_input_default_values_test.go @@ -1,8 +1,9 @@ package astnormalization import ( - "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" "testing" + + "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" ) const testInputDefaultSchema = ` diff --git a/pkg/astparser/parser_test.go b/pkg/astparser/parser_test.go index bd17e5779a..a776e4d02a 100644 --- a/pkg/astparser/parser_test.go +++ b/pkg/astparser/parser_test.go @@ -5,12 +5,12 @@ import ( "os" "testing" + "github.com/stretchr/testify/assert" + "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/lexer/keyword" "github.com/wundergraph/graphql-go-tools/pkg/lexer/position" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" - - "github.com/stretchr/testify/assert" ) func TestParser_Parse(t *testing.T) { diff --git a/pkg/astvalidation/operation_rule_fragments.go b/pkg/astvalidation/operation_rule_fragments.go index f249199c61..31d03579e5 100644 --- a/pkg/astvalidation/operation_rule_fragments.go +++ b/pkg/astvalidation/operation_rule_fragments.go @@ -2,6 +2,7 @@ package astvalidation import ( "bytes" + "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" diff --git a/pkg/astvalidation/rule_populated_type_bodies.go b/pkg/astvalidation/rule_populated_type_bodies.go index 16820288fe..6dc8e4025f 100644 --- a/pkg/astvalidation/rule_populated_type_bodies.go +++ b/pkg/astvalidation/rule_populated_type_bodies.go @@ -2,6 +2,7 @@ package astvalidation import ( "bytes" + "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" diff --git a/pkg/engine/datasource/graphql_datasource/graphql_subscription_client_test.go b/pkg/engine/datasource/graphql_datasource/graphql_subscription_client_test.go index d0cfdb09e3..af69b45806 100644 --- a/pkg/engine/datasource/graphql_datasource/graphql_subscription_client_test.go +++ b/pkg/engine/datasource/graphql_datasource/graphql_subscription_client_test.go @@ -11,11 +11,10 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - "github.com/buger/jsonparser" ll "github.com/jensneuse/abstractlogger" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "go.uber.org/atomic" "go.uber.org/zap" "nhooyr.io/websocket" diff --git a/pkg/engine/datasource/graphql_datasource/graphql_tws_handler_test.go b/pkg/engine/datasource/graphql_datasource/graphql_tws_handler_test.go index 9979085562..079795bef5 100644 --- a/pkg/engine/datasource/graphql_datasource/graphql_tws_handler_test.go +++ b/pkg/engine/datasource/graphql_datasource/graphql_tws_handler_test.go @@ -7,9 +7,8 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "nhooyr.io/websocket" ) diff --git a/pkg/engine/datasource/graphql_datasource/graphql_ws_handler_test.go b/pkg/engine/datasource/graphql_datasource/graphql_ws_handler_test.go index 0f8737143c..7a59cf4e85 100644 --- a/pkg/engine/datasource/graphql_datasource/graphql_ws_handler_test.go +++ b/pkg/engine/datasource/graphql_datasource/graphql_ws_handler_test.go @@ -8,9 +8,8 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "nhooyr.io/websocket" ) diff --git a/pkg/engine/datasource/httpclient/httpclient_test.go b/pkg/engine/datasource/httpclient/httpclient_test.go index cd127e0116..6fa28886a8 100644 --- a/pkg/engine/datasource/httpclient/httpclient_test.go +++ b/pkg/engine/datasource/httpclient/httpclient_test.go @@ -183,7 +183,10 @@ func TestHttpClientDo(t *testing.T) { assert.NoError(t, err) assert.Equal(t, string(body), string(actualBody)) gzipWriter := gzip.NewWriter(w) - defer gzipWriter.Close() + defer func(gzipWriter *gzip.Writer) { + err := gzipWriter.Close() + assert.NoError(t, err) + }(gzipWriter) w.Header().Set("Content-Encoding", "gzip") _, err = gzipWriter.Write([]byte("ok")) assert.NoError(t, err) diff --git a/pkg/engine/datasource/httpclient/nethttpclient.go b/pkg/engine/datasource/httpclient/nethttpclient.go index 5acae62332..675b85109e 100644 --- a/pkg/engine/datasource/httpclient/nethttpclient.go +++ b/pkg/engine/datasource/httpclient/nethttpclient.go @@ -97,7 +97,9 @@ func Do(client *http.Client, ctx context.Context, requestInput []byte, out io.Wr if err != nil { return err } - defer response.Body.Close() + defer func(Body io.ReadCloser) { + err = response.Body.Close() + }(response.Body) respReader, err := respBodyReader(request, response) if err != nil { diff --git a/pkg/execution/datasource_pipeline_test.go b/pkg/execution/datasource_pipeline_test.go index 1f21aebf7d..6848d1fbb2 100644 --- a/pkg/execution/datasource_pipeline_test.go +++ b/pkg/execution/datasource_pipeline_test.go @@ -19,7 +19,12 @@ func TestPipelineDataSource_Resolve(t *testing.T) { t.Fatal(err) } - defer configFile.Close() + defer func(configFile *os.File) { + err := configFile.Close() + if err != nil { + t.Fatalf("Failed to close configFile: %s", err) + } + }(configFile) var pipeline pipe.Pipeline err = pipeline.FromConfig(configFile) diff --git a/pkg/execution/execution_test.go b/pkg/execution/execution_test.go index 38fd035548..525cfe8b73 100644 --- a/pkg/execution/execution_test.go +++ b/pkg/execution/execution_test.go @@ -2004,7 +2004,12 @@ func TestExecutor_HTTPJSONDataSourceWithBody(t *testing.T) { t.Fatal(err) return } - defer r.Body.Close() + defer func(Body io.ReadCloser) { + err := Body.Close() + if err != nil { + t.Fatal(err) + } + }(r.Body) strData := string(data) _ = strData @@ -2496,7 +2501,12 @@ func TestExecutor_HTTPJSONDataSourceWithBodyComplexPlayload(t *testing.T) { t.Fatal(err) return } - defer r.Body.Close() + defer func(Body io.ReadCloser) { + err := Body.Close() + if err != nil { + t.Fatalf("Failed to close body: %s", err) + } + }(r.Body) gotString := prettyJSON(bytes.NewReader(data)) diff --git a/pkg/execution/planning.go b/pkg/execution/planning.go index 5f63f624ed..a95f9df5c4 100644 --- a/pkg/execution/planning.go +++ b/pkg/execution/planning.go @@ -405,7 +405,9 @@ func (p *planningVisitor) pipelineTransformation(directive int) *PipelineTransfo if err != nil { return nil } - defer reader.Close() + defer func(reader *os.File) { + err = reader.Close() + }(reader) configReader = reader } configStringValue, ok := p.definition.DirectiveArgumentValueByName(directive, literal.PIPELINE_CONFIG_STRING) diff --git a/pkg/federation/schema.go b/pkg/federation/schema.go index 874ac58c25..88315b268c 100644 --- a/pkg/federation/schema.go +++ b/pkg/federation/schema.go @@ -2,12 +2,12 @@ package federation import ( "fmt" - "github.com/wundergraph/graphql-go-tools/pkg/asttransform" "strings" "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astparser" "github.com/wundergraph/graphql-go-tools/pkg/astprinter" + "github.com/wundergraph/graphql-go-tools/pkg/asttransform" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" "github.com/wundergraph/graphql-go-tools/pkg/federation/sdlmerge" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" diff --git a/pkg/federation/schema_test.go b/pkg/federation/schema_test.go index ac51e1bbe2..b59ed934ea 100644 --- a/pkg/federation/schema_test.go +++ b/pkg/federation/schema_test.go @@ -1,10 +1,11 @@ package federation import ( - "github.com/wundergraph/graphql-go-tools/pkg/testing/goldie" "testing" "github.com/stretchr/testify/assert" + + "github.com/wundergraph/graphql-go-tools/pkg/testing/goldie" ) func TestSchemaBuilder_BuildFederationSchema(t *testing.T) { diff --git a/pkg/federation/sdlmerge/sdlmerge.go b/pkg/federation/sdlmerge/sdlmerge.go index 78abf0ac41..d7bff33bee 100644 --- a/pkg/federation/sdlmerge/sdlmerge.go +++ b/pkg/federation/sdlmerge/sdlmerge.go @@ -2,16 +2,16 @@ package sdlmerge import ( "fmt" - "github.com/wundergraph/graphql-go-tools/pkg/asttransform" - "github.com/wundergraph/graphql-go-tools/pkg/astvalidation" - "github.com/wundergraph/graphql-go-tools/pkg/engine/plan" "strings" "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astnormalization" "github.com/wundergraph/graphql-go-tools/pkg/astparser" "github.com/wundergraph/graphql-go-tools/pkg/astprinter" + "github.com/wundergraph/graphql-go-tools/pkg/asttransform" + "github.com/wundergraph/graphql-go-tools/pkg/astvalidation" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" + "github.com/wundergraph/graphql-go-tools/pkg/engine/plan" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" ) diff --git a/pkg/graphql/execution_engine_v2.go b/pkg/graphql/execution_engine_v2.go index 8ca7f3bd95..ba724c057f 100644 --- a/pkg/graphql/execution_engine_v2.go +++ b/pkg/graphql/execution_engine_v2.go @@ -14,11 +14,10 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/jensneuse/abstractlogger" - "github.com/wundergraph/graphql-go-tools/pkg/engine/datasource/introspection_datasource" - "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astprinter" "github.com/wundergraph/graphql-go-tools/pkg/engine/datasource/httpclient" + "github.com/wundergraph/graphql-go-tools/pkg/engine/datasource/introspection_datasource" "github.com/wundergraph/graphql-go-tools/pkg/engine/plan" "github.com/wundergraph/graphql-go-tools/pkg/engine/resolve" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" diff --git a/pkg/graphql/execution_engine_v2_norace_test.go b/pkg/graphql/execution_engine_v2_norace_test.go index cbb07b2faf..19c3afd4b5 100644 --- a/pkg/graphql/execution_engine_v2_norace_test.go +++ b/pkg/graphql/execution_engine_v2_norace_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting" "github.com/wundergraph/graphql-go-tools/pkg/testing/flags" ) diff --git a/pkg/http/http.go b/pkg/http/http.go index a4ce9a3bbd..60456c52a5 100644 --- a/pkg/http/http.go +++ b/pkg/http/http.go @@ -7,6 +7,7 @@ import ( "net/http" log "github.com/jensneuse/abstractlogger" + "github.com/wundergraph/graphql-go-tools/pkg/pool" ) diff --git a/pkg/imports/graphql_file.go b/pkg/imports/graphql_file.go index c307108920..0bd0c28ae8 100644 --- a/pkg/imports/graphql_file.go +++ b/pkg/imports/graphql_file.go @@ -52,7 +52,9 @@ func (g GraphQLFile) renderSelf(printFilePath bool, out io.Writer) error { if err != nil { return err } - defer file.Close() + defer func(file *os.File) { + err = file.Close() + }(file) if printFilePath { err = g.renderFilePath(out) diff --git a/pkg/operationreport/operationreport_test.go b/pkg/operationreport/operationreport_test.go index afd5ef008d..369d1d0662 100644 --- a/pkg/operationreport/operationreport_test.go +++ b/pkg/operationreport/operationreport_test.go @@ -3,8 +3,9 @@ package operationreport import ( "errors" "fmt" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestExternalErrorMessage(t *testing.T) { diff --git a/pkg/subscription/websocket/client_test.go b/pkg/subscription/websocket/client_test.go index 85be6940e2..afc1998a7c 100644 --- a/pkg/subscription/websocket/client_test.go +++ b/pkg/subscription/websocket/client_test.go @@ -108,7 +108,10 @@ func TestClient_ReadFromClient(t *testing.T) { t.Run("before read", func(t *testing.T) { _, connToClient := net.Pipe() websocketClient := NewClient(abstractlogger.NoopLogger, connToClient) - defer connToClient.Close() + defer func(connToClient net.Conn) { + err := connToClient.Close() + assert.NoError(t, err) + }(connToClient) websocketClient.isClosedConnection = true assert.Eventually(t, func() bool { diff --git a/pkg/testing/federationtesting/federation_integration_test.go b/pkg/testing/federationtesting/federation_integration_test.go index 8ea316da81..c1d9ad16c5 100644 --- a/pkg/testing/federationtesting/federation_integration_test.go +++ b/pkg/testing/federationtesting/federation_integration_test.go @@ -7,8 +7,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/jensneuse/abstractlogger" - "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "path" @@ -16,6 +14,9 @@ import ( "testing" "time" + "github.com/jensneuse/abstractlogger" + "github.com/stretchr/testify/assert" + accounts "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/accounts/graph" "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/gateway" products "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/products/graph" diff --git a/pkg/testing/federationtesting/gateway/datasource_poller.go b/pkg/testing/federationtesting/gateway/datasource_poller.go index c1cf1f9dcb..87ea5e284c 100644 --- a/pkg/testing/federationtesting/gateway/datasource_poller.go +++ b/pkg/testing/federationtesting/gateway/datasource_poller.go @@ -185,7 +185,12 @@ func (d *DatasourcePollerPoller) fetchServiceSDL(ctx context.Context, serviceURL return "", fmt.Errorf("do request: %v", err) } - defer resp.Body.Close() + defer func(Body io.ReadCloser) { + err = Body.Close() + if err != nil { + log.Printf("Failed to close response body: %s\n", err) + } + }(resp.Body) var result struct { Data struct { diff --git a/pkg/testing/federationtesting/gateway/main.go b/pkg/testing/federationtesting/gateway/main.go index c5e0aa5c55..cb23cd9c11 100644 --- a/pkg/testing/federationtesting/gateway/main.go +++ b/pkg/testing/federationtesting/gateway/main.go @@ -7,9 +7,8 @@ import ( "github.com/gobwas/ws" log "github.com/jensneuse/abstractlogger" - http2 "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/gateway/http" - "github.com/wundergraph/graphql-go-tools/pkg/graphql" + http2 "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/gateway/http" ) func NewDatasource(serviceConfig []ServiceConfig, httpClient *http.Client) *DatasourcePollerPoller { diff --git a/pkg/testing/federationtesting/graphql_client_test.go b/pkg/testing/federationtesting/graphql_client_test.go index 777646819e..8573fe52b5 100644 --- a/pkg/testing/federationtesting/graphql_client_test.go +++ b/pkg/testing/federationtesting/graphql_client_test.go @@ -103,7 +103,12 @@ func (g *GraphqlClient) Subscription(ctx context.Context, addr, queryFilePath st // 4. start receiving messages from subscription go func() { - defer conn.Close() + defer func(conn net.Conn) { + err := conn.Close() + if err != nil { + assert.NoError(t, err) + } + }(conn) defer close(messageCh) for { From 2aa76e87154e751c17ce10dd5710fc994a2386ba Mon Sep 17 00:00:00 2001 From: spetrunin Date: Fri, 5 Sep 2025 21:38:03 +0300 Subject: [PATCH 3/3] Revert "feat: upgrade all components to go 1.25" This reverts commit 38c6a8ecb3576d9ae8f44129a81552d623af0fba. --- pkg/ast/ast_node_kind_test.go | 3 +-- pkg/ast/ast_root_operation_type_definition.go | 1 - .../inject_input_default_values.go | 1 - .../inject_input_default_values_test.go | 3 +-- pkg/astparser/parser_test.go | 4 ++-- pkg/astvalidation/operation_rule_fragments.go | 1 - pkg/astvalidation/rule_populated_type_bodies.go | 1 - .../graphql_subscription_client_test.go | 3 ++- .../graphql_datasource/graphql_tws_handler_test.go | 3 ++- .../graphql_datasource/graphql_ws_handler_test.go | 3 ++- .../datasource/httpclient/httpclient_test.go | 5 +---- pkg/engine/datasource/httpclient/nethttpclient.go | 4 +--- pkg/execution/datasource_pipeline_test.go | 7 +------ pkg/execution/execution_test.go | 14 ++------------ pkg/execution/planning.go | 4 +--- pkg/federation/schema.go | 2 +- pkg/federation/schema_test.go | 3 +-- pkg/federation/sdlmerge/sdlmerge.go | 6 +++--- pkg/graphql/execution_engine_v2.go | 3 ++- pkg/graphql/execution_engine_v2_norace_test.go | 1 - pkg/http/http.go | 1 - pkg/imports/graphql_file.go | 4 +--- pkg/operationreport/operationreport_test.go | 3 +-- pkg/subscription/websocket/client_test.go | 5 +---- .../federation_integration_test.go | 5 ++--- .../federationtesting/gateway/datasource_poller.go | 7 +------ pkg/testing/federationtesting/gateway/main.go | 3 ++- .../federationtesting/graphql_client_test.go | 7 +------ 28 files changed, 32 insertions(+), 75 deletions(-) diff --git a/pkg/ast/ast_node_kind_test.go b/pkg/ast/ast_node_kind_test.go index 2999daf49c..bbc6326323 100644 --- a/pkg/ast/ast_node_kind_test.go +++ b/pkg/ast/ast_node_kind_test.go @@ -1,9 +1,8 @@ package ast import ( - "testing" - "github.com/stretchr/testify/assert" + "testing" ) func TestNodeKindIsAbstractType(t *testing.T) { diff --git a/pkg/ast/ast_root_operation_type_definition.go b/pkg/ast/ast_root_operation_type_definition.go index bd8fff725d..0f252dbc82 100644 --- a/pkg/ast/ast_root_operation_type_definition.go +++ b/pkg/ast/ast_root_operation_type_definition.go @@ -2,7 +2,6 @@ package ast import ( "bytes" - "github.com/wundergraph/graphql-go-tools/pkg/lexer/position" ) diff --git a/pkg/astnormalization/inject_input_default_values.go b/pkg/astnormalization/inject_input_default_values.go index ba116aa8a5..3ddb81fb75 100644 --- a/pkg/astnormalization/inject_input_default_values.go +++ b/pkg/astnormalization/inject_input_default_values.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/buger/jsonparser" - "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" ) diff --git a/pkg/astnormalization/inject_input_default_values_test.go b/pkg/astnormalization/inject_input_default_values_test.go index ade8bd7be0..82e24cfc45 100644 --- a/pkg/astnormalization/inject_input_default_values_test.go +++ b/pkg/astnormalization/inject_input_default_values_test.go @@ -1,9 +1,8 @@ package astnormalization import ( - "testing" - "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" + "testing" ) const testInputDefaultSchema = ` diff --git a/pkg/astparser/parser_test.go b/pkg/astparser/parser_test.go index a776e4d02a..bd17e5779a 100644 --- a/pkg/astparser/parser_test.go +++ b/pkg/astparser/parser_test.go @@ -5,12 +5,12 @@ import ( "os" "testing" - "github.com/stretchr/testify/assert" - "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/lexer/keyword" "github.com/wundergraph/graphql-go-tools/pkg/lexer/position" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" + + "github.com/stretchr/testify/assert" ) func TestParser_Parse(t *testing.T) { diff --git a/pkg/astvalidation/operation_rule_fragments.go b/pkg/astvalidation/operation_rule_fragments.go index 31d03579e5..f249199c61 100644 --- a/pkg/astvalidation/operation_rule_fragments.go +++ b/pkg/astvalidation/operation_rule_fragments.go @@ -2,7 +2,6 @@ package astvalidation import ( "bytes" - "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" diff --git a/pkg/astvalidation/rule_populated_type_bodies.go b/pkg/astvalidation/rule_populated_type_bodies.go index 6dc8e4025f..16820288fe 100644 --- a/pkg/astvalidation/rule_populated_type_bodies.go +++ b/pkg/astvalidation/rule_populated_type_bodies.go @@ -2,7 +2,6 @@ package astvalidation import ( "bytes" - "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" diff --git a/pkg/engine/datasource/graphql_datasource/graphql_subscription_client_test.go b/pkg/engine/datasource/graphql_datasource/graphql_subscription_client_test.go index af69b45806..d0cfdb09e3 100644 --- a/pkg/engine/datasource/graphql_datasource/graphql_subscription_client_test.go +++ b/pkg/engine/datasource/graphql_datasource/graphql_subscription_client_test.go @@ -11,10 +11,11 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/buger/jsonparser" ll "github.com/jensneuse/abstractlogger" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "go.uber.org/atomic" "go.uber.org/zap" "nhooyr.io/websocket" diff --git a/pkg/engine/datasource/graphql_datasource/graphql_tws_handler_test.go b/pkg/engine/datasource/graphql_datasource/graphql_tws_handler_test.go index 079795bef5..9979085562 100644 --- a/pkg/engine/datasource/graphql_datasource/graphql_tws_handler_test.go +++ b/pkg/engine/datasource/graphql_datasource/graphql_tws_handler_test.go @@ -7,8 +7,9 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/stretchr/testify/assert" "nhooyr.io/websocket" ) diff --git a/pkg/engine/datasource/graphql_datasource/graphql_ws_handler_test.go b/pkg/engine/datasource/graphql_datasource/graphql_ws_handler_test.go index 7a59cf4e85..0f8737143c 100644 --- a/pkg/engine/datasource/graphql_datasource/graphql_ws_handler_test.go +++ b/pkg/engine/datasource/graphql_datasource/graphql_ws_handler_test.go @@ -8,8 +8,9 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/stretchr/testify/assert" "nhooyr.io/websocket" ) diff --git a/pkg/engine/datasource/httpclient/httpclient_test.go b/pkg/engine/datasource/httpclient/httpclient_test.go index 6fa28886a8..cd127e0116 100644 --- a/pkg/engine/datasource/httpclient/httpclient_test.go +++ b/pkg/engine/datasource/httpclient/httpclient_test.go @@ -183,10 +183,7 @@ func TestHttpClientDo(t *testing.T) { assert.NoError(t, err) assert.Equal(t, string(body), string(actualBody)) gzipWriter := gzip.NewWriter(w) - defer func(gzipWriter *gzip.Writer) { - err := gzipWriter.Close() - assert.NoError(t, err) - }(gzipWriter) + defer gzipWriter.Close() w.Header().Set("Content-Encoding", "gzip") _, err = gzipWriter.Write([]byte("ok")) assert.NoError(t, err) diff --git a/pkg/engine/datasource/httpclient/nethttpclient.go b/pkg/engine/datasource/httpclient/nethttpclient.go index 675b85109e..5acae62332 100644 --- a/pkg/engine/datasource/httpclient/nethttpclient.go +++ b/pkg/engine/datasource/httpclient/nethttpclient.go @@ -97,9 +97,7 @@ func Do(client *http.Client, ctx context.Context, requestInput []byte, out io.Wr if err != nil { return err } - defer func(Body io.ReadCloser) { - err = response.Body.Close() - }(response.Body) + defer response.Body.Close() respReader, err := respBodyReader(request, response) if err != nil { diff --git a/pkg/execution/datasource_pipeline_test.go b/pkg/execution/datasource_pipeline_test.go index 6848d1fbb2..1f21aebf7d 100644 --- a/pkg/execution/datasource_pipeline_test.go +++ b/pkg/execution/datasource_pipeline_test.go @@ -19,12 +19,7 @@ func TestPipelineDataSource_Resolve(t *testing.T) { t.Fatal(err) } - defer func(configFile *os.File) { - err := configFile.Close() - if err != nil { - t.Fatalf("Failed to close configFile: %s", err) - } - }(configFile) + defer configFile.Close() var pipeline pipe.Pipeline err = pipeline.FromConfig(configFile) diff --git a/pkg/execution/execution_test.go b/pkg/execution/execution_test.go index 525cfe8b73..38fd035548 100644 --- a/pkg/execution/execution_test.go +++ b/pkg/execution/execution_test.go @@ -2004,12 +2004,7 @@ func TestExecutor_HTTPJSONDataSourceWithBody(t *testing.T) { t.Fatal(err) return } - defer func(Body io.ReadCloser) { - err := Body.Close() - if err != nil { - t.Fatal(err) - } - }(r.Body) + defer r.Body.Close() strData := string(data) _ = strData @@ -2501,12 +2496,7 @@ func TestExecutor_HTTPJSONDataSourceWithBodyComplexPlayload(t *testing.T) { t.Fatal(err) return } - defer func(Body io.ReadCloser) { - err := Body.Close() - if err != nil { - t.Fatalf("Failed to close body: %s", err) - } - }(r.Body) + defer r.Body.Close() gotString := prettyJSON(bytes.NewReader(data)) diff --git a/pkg/execution/planning.go b/pkg/execution/planning.go index a95f9df5c4..5f63f624ed 100644 --- a/pkg/execution/planning.go +++ b/pkg/execution/planning.go @@ -405,9 +405,7 @@ func (p *planningVisitor) pipelineTransformation(directive int) *PipelineTransfo if err != nil { return nil } - defer func(reader *os.File) { - err = reader.Close() - }(reader) + defer reader.Close() configReader = reader } configStringValue, ok := p.definition.DirectiveArgumentValueByName(directive, literal.PIPELINE_CONFIG_STRING) diff --git a/pkg/federation/schema.go b/pkg/federation/schema.go index 88315b268c..874ac58c25 100644 --- a/pkg/federation/schema.go +++ b/pkg/federation/schema.go @@ -2,12 +2,12 @@ package federation import ( "fmt" + "github.com/wundergraph/graphql-go-tools/pkg/asttransform" "strings" "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astparser" "github.com/wundergraph/graphql-go-tools/pkg/astprinter" - "github.com/wundergraph/graphql-go-tools/pkg/asttransform" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" "github.com/wundergraph/graphql-go-tools/pkg/federation/sdlmerge" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" diff --git a/pkg/federation/schema_test.go b/pkg/federation/schema_test.go index b59ed934ea..ac51e1bbe2 100644 --- a/pkg/federation/schema_test.go +++ b/pkg/federation/schema_test.go @@ -1,11 +1,10 @@ package federation import ( + "github.com/wundergraph/graphql-go-tools/pkg/testing/goldie" "testing" "github.com/stretchr/testify/assert" - - "github.com/wundergraph/graphql-go-tools/pkg/testing/goldie" ) func TestSchemaBuilder_BuildFederationSchema(t *testing.T) { diff --git a/pkg/federation/sdlmerge/sdlmerge.go b/pkg/federation/sdlmerge/sdlmerge.go index d7bff33bee..78abf0ac41 100644 --- a/pkg/federation/sdlmerge/sdlmerge.go +++ b/pkg/federation/sdlmerge/sdlmerge.go @@ -2,16 +2,16 @@ package sdlmerge import ( "fmt" + "github.com/wundergraph/graphql-go-tools/pkg/asttransform" + "github.com/wundergraph/graphql-go-tools/pkg/astvalidation" + "github.com/wundergraph/graphql-go-tools/pkg/engine/plan" "strings" "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astnormalization" "github.com/wundergraph/graphql-go-tools/pkg/astparser" "github.com/wundergraph/graphql-go-tools/pkg/astprinter" - "github.com/wundergraph/graphql-go-tools/pkg/asttransform" - "github.com/wundergraph/graphql-go-tools/pkg/astvalidation" "github.com/wundergraph/graphql-go-tools/pkg/astvisitor" - "github.com/wundergraph/graphql-go-tools/pkg/engine/plan" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" ) diff --git a/pkg/graphql/execution_engine_v2.go b/pkg/graphql/execution_engine_v2.go index ba724c057f..8ca7f3bd95 100644 --- a/pkg/graphql/execution_engine_v2.go +++ b/pkg/graphql/execution_engine_v2.go @@ -14,10 +14,11 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/jensneuse/abstractlogger" + "github.com/wundergraph/graphql-go-tools/pkg/engine/datasource/introspection_datasource" + "github.com/wundergraph/graphql-go-tools/pkg/ast" "github.com/wundergraph/graphql-go-tools/pkg/astprinter" "github.com/wundergraph/graphql-go-tools/pkg/engine/datasource/httpclient" - "github.com/wundergraph/graphql-go-tools/pkg/engine/datasource/introspection_datasource" "github.com/wundergraph/graphql-go-tools/pkg/engine/plan" "github.com/wundergraph/graphql-go-tools/pkg/engine/resolve" "github.com/wundergraph/graphql-go-tools/pkg/operationreport" diff --git a/pkg/graphql/execution_engine_v2_norace_test.go b/pkg/graphql/execution_engine_v2_norace_test.go index 19c3afd4b5..cbb07b2faf 100644 --- a/pkg/graphql/execution_engine_v2_norace_test.go +++ b/pkg/graphql/execution_engine_v2_norace_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting" "github.com/wundergraph/graphql-go-tools/pkg/testing/flags" ) diff --git a/pkg/http/http.go b/pkg/http/http.go index 60456c52a5..a4ce9a3bbd 100644 --- a/pkg/http/http.go +++ b/pkg/http/http.go @@ -7,7 +7,6 @@ import ( "net/http" log "github.com/jensneuse/abstractlogger" - "github.com/wundergraph/graphql-go-tools/pkg/pool" ) diff --git a/pkg/imports/graphql_file.go b/pkg/imports/graphql_file.go index 0bd0c28ae8..c307108920 100644 --- a/pkg/imports/graphql_file.go +++ b/pkg/imports/graphql_file.go @@ -52,9 +52,7 @@ func (g GraphQLFile) renderSelf(printFilePath bool, out io.Writer) error { if err != nil { return err } - defer func(file *os.File) { - err = file.Close() - }(file) + defer file.Close() if printFilePath { err = g.renderFilePath(out) diff --git a/pkg/operationreport/operationreport_test.go b/pkg/operationreport/operationreport_test.go index 369d1d0662..afd5ef008d 100644 --- a/pkg/operationreport/operationreport_test.go +++ b/pkg/operationreport/operationreport_test.go @@ -3,9 +3,8 @@ package operationreport import ( "errors" "fmt" - "testing" - "github.com/stretchr/testify/assert" + "testing" ) func TestExternalErrorMessage(t *testing.T) { diff --git a/pkg/subscription/websocket/client_test.go b/pkg/subscription/websocket/client_test.go index afc1998a7c..85be6940e2 100644 --- a/pkg/subscription/websocket/client_test.go +++ b/pkg/subscription/websocket/client_test.go @@ -108,10 +108,7 @@ func TestClient_ReadFromClient(t *testing.T) { t.Run("before read", func(t *testing.T) { _, connToClient := net.Pipe() websocketClient := NewClient(abstractlogger.NoopLogger, connToClient) - defer func(connToClient net.Conn) { - err := connToClient.Close() - assert.NoError(t, err) - }(connToClient) + defer connToClient.Close() websocketClient.isClosedConnection = true assert.Eventually(t, func() bool { diff --git a/pkg/testing/federationtesting/federation_integration_test.go b/pkg/testing/federationtesting/federation_integration_test.go index c1d9ad16c5..8ea316da81 100644 --- a/pkg/testing/federationtesting/federation_integration_test.go +++ b/pkg/testing/federationtesting/federation_integration_test.go @@ -7,6 +7,8 @@ import ( "context" "encoding/json" "fmt" + "github.com/jensneuse/abstractlogger" + "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "path" @@ -14,9 +16,6 @@ import ( "testing" "time" - "github.com/jensneuse/abstractlogger" - "github.com/stretchr/testify/assert" - accounts "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/accounts/graph" "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/gateway" products "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/products/graph" diff --git a/pkg/testing/federationtesting/gateway/datasource_poller.go b/pkg/testing/federationtesting/gateway/datasource_poller.go index 87ea5e284c..c1cf1f9dcb 100644 --- a/pkg/testing/federationtesting/gateway/datasource_poller.go +++ b/pkg/testing/federationtesting/gateway/datasource_poller.go @@ -185,12 +185,7 @@ func (d *DatasourcePollerPoller) fetchServiceSDL(ctx context.Context, serviceURL return "", fmt.Errorf("do request: %v", err) } - defer func(Body io.ReadCloser) { - err = Body.Close() - if err != nil { - log.Printf("Failed to close response body: %s\n", err) - } - }(resp.Body) + defer resp.Body.Close() var result struct { Data struct { diff --git a/pkg/testing/federationtesting/gateway/main.go b/pkg/testing/federationtesting/gateway/main.go index cb23cd9c11..c5e0aa5c55 100644 --- a/pkg/testing/federationtesting/gateway/main.go +++ b/pkg/testing/federationtesting/gateway/main.go @@ -7,8 +7,9 @@ import ( "github.com/gobwas/ws" log "github.com/jensneuse/abstractlogger" - "github.com/wundergraph/graphql-go-tools/pkg/graphql" http2 "github.com/wundergraph/graphql-go-tools/pkg/testing/federationtesting/gateway/http" + + "github.com/wundergraph/graphql-go-tools/pkg/graphql" ) func NewDatasource(serviceConfig []ServiceConfig, httpClient *http.Client) *DatasourcePollerPoller { diff --git a/pkg/testing/federationtesting/graphql_client_test.go b/pkg/testing/federationtesting/graphql_client_test.go index 8573fe52b5..777646819e 100644 --- a/pkg/testing/federationtesting/graphql_client_test.go +++ b/pkg/testing/federationtesting/graphql_client_test.go @@ -103,12 +103,7 @@ func (g *GraphqlClient) Subscription(ctx context.Context, addr, queryFilePath st // 4. start receiving messages from subscription go func() { - defer func(conn net.Conn) { - err := conn.Close() - if err != nil { - assert.NoError(t, err) - } - }(conn) + defer conn.Close() defer close(messageCh) for {