99designs / 99designs/gqlgen

gqlgen requires a go mod tidy which isn't possible

Đang mở
#2,668 0 bình luận 0 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?
I run `gqlgen` (installed in `home/go/bin`) and reveive this error:
```
modelgen: package could not be loaded: github.com/99designs/gqlgen/graphql.Boolean: packages.Load: err: exit status 1: stderr: go: updates to go.mod needed; to update it:
go mod tidy
```
Therefore, I run `go mod tidy`, which fails with:
```
github.com/my_company/my_project/internal/cli imports
github.com/my_company/my_project/internal/app/graphql: no matching versions for query "latest"
github.com/my_company/my_project/eventing imports
github.com/my_company/my_project/internal/graphql/models: no matching versions for query "latest"
```
I guess that's b/c `internal/app/graphql` and `internal/graphql/models` don't exist yet (I want `gqlgen` to create files here).

I recall that in the past I solved that problem somehow by flddling with `get get -u` commands, but after reinstalling Ubuntu this time I don't really manage it. I'ld also love to understand what the problem actually is instead of just mindlessly hammering some commands. ;)

When I can create the imported module by hand with an empty dummy file in it, `go mod tidy` works, and so does `gqlgen` afterward. Maybe it would make help if `gqlgen` created its target files before it call `go mod tidy`?

### What did you expect?
Ideally, `gqlgen` generates the file without requiring `go mod tidy`, or I can run `go mod tidy` first (if that solved the issue).
### Minimal graphql.schema and models to reproduce
`graphql.schema`:
```yaml
schema: api/my_entity.graphqls
exec:
filename: internal/app/graphql/gql_exec_gen.go
package: graphql
model:
filename: internal/graphql/models/models_gen.go
package: models
resolver:
filename: internal/graphql/resolver.go
type: Resolver
package: graphql
```
`api/my_entity.graphqls`:
```graphql
type MyEntitiy {
id: ID!
}

type Query {
myEntity(id: ID!): MyEntity
}

```

### versions
github.com/99designs/gqlgen v0.17.32
go1.20.5 linux/amd64

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

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

Hướng nghiên cứu

Xem xét bước tạo model trong codegen của gqlgen, nhiều khả năng nằm trong internal/codegen hoặc cmd/gen.go. Vấn đề là go mod tidy thất bại vì các thư mục đích dành cho các tệp được tạo chưa tồn tại. Kiểm tra cách gqlgen tương tác với các module Go và liệu nó có thể tạo các thư mục hoặc tệp giữ chỗ trước khi gọi go mod tidy hay không. Chạy các bài kiểm thử hiện có liên quan đến việc tạo mã sẽ giúp xác minh mọi bản sửa lỗi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go
Lĩnh vực
build-system
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

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.