Skip to content

Commit 414fe20

Browse files
pavelnikolovCopilot
andauthored
Small improvements (#730)
* chore: ignore dot files Co-authored-by: Copilot <copilot@github.com> * chore: go ignore node_modules * test: use noop test panic logger * refactor: query errors str builder * docs: update testdata readme --------- Co-authored-by: Copilot <copilot@github.com>
2 parents 40394f8 + b3545b8 commit 414fe20

5 files changed

Lines changed: 17 additions & 10 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
/internal/validation/testdata/graphql-js
44
/internal/validation/testdata/node_modules
55
/vendor
6+
/specs
7+
/.*
8+
/!.github/workflows

errors/errors.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package errors
22

33
import (
44
"fmt"
5+
"strings"
56
)
67

78
type QueryError struct {
@@ -42,11 +43,12 @@ func (err *QueryError) Error() string {
4243
if err == nil {
4344
return "<nil>"
4445
}
45-
str := fmt.Sprintf("graphql: %s", err.Message)
46+
var str strings.Builder
47+
fmt.Fprintf(&str, "graphql: %s", err.Message)
4648
for _, loc := range err.Locations {
47-
str += fmt.Sprintf(" (line %d, column %d)", loc.Line, loc.Column)
49+
fmt.Fprintf(&str, " (line %d, column %d)", loc.Line, loc.Column)
4850
}
49-
return str
51+
return str.String()
5052
}
5153

5254
func (err *QueryError) Unwrap() error {

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ require (
1515
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
1616
go.opentelemetry.io/otel/metric v1.43.0 // indirect
1717
)
18+
19+
ignore (
20+
"./internal/validation/testdata/node_modules/**"
21+
)

internal/validation/testdata/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@ go generate .
1212

1313
## How it works
1414

15-
A Node.js project is used to pull in graphql-js as a dependency. The `export.cjs` script runs with Node,
16-
transpiles graphql-js TypeScript files on the fly, loads selected validation test files with a lightweight in-process Mocha shim, and captures expected validation errors into `tests.json`. These test cases in the JSON file are then used to drive the Go tests.
15+
A Node.js project is used to pull in graphql-js as a dependency. The `export.cjs` script runs with Node, transpiles graphql-js TypeScript files on the fly, loads selected validation test files with a lightweight in-process Mocha shim, and captures expected validation errors into `tests.json`. These test cases in the JSON file are then used to drive the Go tests.
1716

18-
Some upstream validation suites are intentionally disabled in `export.cjs` when
19-
they rely on currently unsupported behavior (for example, subscription-only
20-
fixtures) or known parser/validation parity gaps. Each disabled import has an
21-
inline rationale and should be re-evaluated as parity work progresses.
17+
Some upstream validation suites are intentionally disabled in `export.cjs` when they rely on currently unsupported behavior (for example, subscription-only fixtures) or known parser/validation parity gaps. Each disabled import has an inline rationale and should be re-evaluated as parity work progresses.
2218

2319
## Updating dependency
2420

subscription_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
graphql "github.com/graph-gophers/graphql-go"
1313
qerrors "github.com/graph-gophers/graphql-go/errors"
1414
"github.com/graph-gophers/graphql-go/gqltesting"
15+
"github.com/graph-gophers/graphql-go/log"
1516
)
1617

1718
type rootResolver struct {
@@ -606,6 +607,7 @@ func (r *subscriptionsPanicInResolver) OnPanic() <-chan string {
606607
}
607608

608609
func TestSchemaSubscribe_PanicInResolver(t *testing.T) {
610+
noop := log.LoggerFunc(func(_ context.Context, _ any) {})
609611
r := &struct {
610612
*subscriptionsPanicInResolver
611613
Name string
@@ -620,7 +622,7 @@ func TestSchemaSubscribe_PanicInResolver(t *testing.T) {
620622
type Subscription {
621623
onPanic : String!
622624
}
623-
`, r, graphql.UseFieldResolvers()),
625+
`, r, graphql.UseFieldResolvers(), graphql.Logger(noop)),
624626
Query: `
625627
subscription {
626628
onPanic

0 commit comments

Comments
 (0)