99designs / 99designs/gqlgen

Plugin code gen fails in vendor mode

未关闭
#2,710 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
10.8k
派生
1.3k
平均合并
2 天 36 分钟
30 天内合并 PR
26

描述

### What happened?

When using `-mod=vendor`, the project should properly account for imports; however, one of the imports is not added to the mod file due to it being specified only in the go template file resulting in:

```
merging type systems failed: unable to build object definition: unable to find type: github.com/99designs/gqlgen/graphql/introspection.Schema
```

The offending file is `github.com/99designs/gqlgen/codegen/root_.gotpl` where `{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }}` is reserved but not imported explicitly anywhere.

Using `_ "github.com/99designs/gqlgen/graphql/introspection"` fixes the issue but this should probably be included in the project and not in projects importing the package.

**Keep in mind** this is in a `plugin` project that imports gqlgen.

### What did you expect?

Code generation to work successfully after running `go mod vendor` and `go mod tidy` in `vendor mode` via `-mod=vendor` set in `GOFLAGS`.

### Minimal graphql.schema and models to reproduce

N/A

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

`github.com/99designs/gqlgen v0.17.34`

- `go version`?

`go version go1.20.5 darwin/arm64`

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。