99designs / 99designs/gqlgen

unused parameter: ctx warnings in generated.go

Đang mở
#3,004 0 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
10.8k
Fork
1.3k
Merge trung bình
2 ngày 36 phút
Pull request đã merge (30 ngày)
26

Mô tả

### What happened?

The code in `generated.go` contains unused parameters that triggers warnings in vscode (e.g. "unused parameter: ctx"). For example, `generated.go` produces code like this:

```go
func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Query",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "id":
return ec.fieldContext_Todo_id(ctx, field)
case "text":
return ec.fieldContext_Todo_text(ctx, field)
case "done":
return ec.fieldContext_Todo_done(ctx, field)
case "user":
return ec.fieldContext_Todo_user(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name)
},
}
return fc, nil
}
```

### What did you expect?

Generated code not to trigger warnings.

### Minimal graphql.schema and models to reproduce

Running the gqlgen-todos quickstart example produces code that triggers the unused parameter warnings.

### versions
- `go run github.com/99designs/gqlgen version`? 0.17.45
- `go version`? 1.21.6

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.