99designs / 99designs/gqlgen

Directives are ignored when using maps as changesets

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

描述

### What happened?

I have defined some directives on several fields on several input types as described here: https://gqlgen.com/reference/directives/ .

In my application I needed the functionality described here: https://gqlgen.com/reference/changesets/ . So I did override the model for some input types with `map[string]interface{}`.

In the generated code the calls that are related to the directives appear inside the `func (ec *executionContext) unmarshalInputMyInputType(ctx context.Context, obj interface{}) (model.MyInputType, error) {` function, which is never called and there is no way to trigger it manually.

### What did you expect?

I would expect the code that is related to the directives to be independent from the unmarshal function and to still be triggeredor at least be able to call it manually inside my resolvers.

### Minimal graphql.schema and models to reproduce

``` graphql
input MyInputType {
foo: Float @rangeInt(min: 0, max: 10)
}
```

gqlgen.yml
```
models:
MyInputType:
model: "map[string]interface{}"
```

### versions
- `gqlgen version`: v0.14.0
- `go version`: 1.17.2

贡献指南

打开贡献指南

调研方向

该 issue 出现在使用 map[string]interface{} 作为模型时的 input 类型代码生成中。查看生成的 unmarshalInputMyInputType 函数,确认 directive 调用被放置在哪里。检查 gqlgen codegen 包,可能是在 input 类型的反序列化逻辑附近。了解 directive 应如何被触发,以及为什么对于 map 模型会被跳过。运行现有的 directive 和 changesets 测试将有助于验证修复。

由索引模型根据 Issue 内容生成。

评估

技术栈
go
领域
backend-api-design
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

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