99designs / 99designs/gqlgen

OperationContext contains empty variables for variable with query

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

描述

### What happened?

setting up the following for the handler
```go
srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
oc := graphql.GetOperationContext(ctx)
fmt.Printf("%+v", oc.Variables)
return next(ctx)
})
```
prints `map[]`
on the following query

```
query Query {
genConfigJson(id: 1234567)
}
```
The query succeeds and returns data in graphiql

### What did you expect?
the print statement should have printed `{"id":1234567}`

### Minimal graphql.schema and models to reproduce
```graphql
scalar Map

type Query {
genConfigJson(id: [Int!]): [Map!]
}
```

### versions
- `go run github.com/99designs/gqlgen version`?
Initially tried with `v0.17.44`. Updated to `v0.17.49` and it still happens
- `go version`?
`go version go1.22.4 linux/amd64`

贡献指南

打开贡献指南

调研方向

问题在于,对于带有参数的查询,OperationContext.Variables 映射为空。查看 server package 中的 operation context 处理,可能重点关注 operation execution 和 variable parsing 附近的代码。测试应包括设置一个带有 AroundOperations 的 handler,并验证 variables map 包含 query argument。检查变量如何从 request 中提取并传递给 operation context。

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

评估

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

把新 issue 发到你的邮箱

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