99designs / 99designs/gqlgen

Generated resolver go files are not going into sub packages using `follow-schema`

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

描述

Hi there,

### What happened?

I have my `.graphql` files organised into sub-directories, eg `company`, `user` etc

```
server/schema/
company/
company.queries.graphql
company.mutations.graphql
user/
user.queries.graphql
user.mutations.graphql
```

Though I am using `follow-schema` option (see below) to generate resolvers, generated resolver go files are not being organised into sub packages (under `resolver` package). Instead all of them are put directly into main resolver directory.

```
server/resolver/
company.queries.go
company.mutations.go
user.queries.go
user.mutations.go
resolver.go
```

Here is my `gqlgen.yml`

```
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema:
- server/schema/**/*.graphql

# Where should the generated server code go?
exec:
filename: server/generated/generated.go
package: generated

# Uncomment to enable federation
# federation:
# filename: server/generated/federation.go
# package: generated

# Where should any generated models go?
model:
filename: server/model/models_gen.go
package: model

# Where should the resolver implementations go?
resolver:
layout: follow-schema
dir: server/resolver
package: resolver

# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models
# struct_tag: json

# Optional: turn on to use []Thing instead of []*Thing
# omit_slice_element_pointers: false

# Optional: set to speed up generation time by not performing a final validation pass.
# skip_validation: true

# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
- "github.com///server/types"

# This section declares type mapping between the GraphQL and go type systems
#
# The first line in each type will be used as defaults for resolver arguments and
# modelgen, the others will be allowed when binding to fields. Configure them to
# your liking
models:
ID:
model:
- github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
Int:
model:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32

```

### What did you expect?
Generated resolver go files organised into sub-packages

```
server/resolver/
company/
company.queries.go
company.mutations.go
user/
user.queries.go
user.mutations.go
resolver.go
```

### Minimal graphql.schema and models to reproduce
Nothing to do with schema and model I believe. Can be reproduced with any two or more `.graphql` files organised into sub-directories.

### versions
- `go run github.com/99designs/gqlgen version`: v0.17.2
- `go version`: 1.18

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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