How do I pass values from Directive to Resolver through context?
- Linguagem predominante
- Go
- Estrelas
- 10.8k
- Forks
- 1.3k
- Merge médio
- 2d 36min
- PRs com merge (30d)
- 26
Descrição
### What happened?
```
c.Directives.Test = func(ctx context.Context, obj interface{}, next graphql.Resolver, key *string) (interface{}, error) {
ctx = context.WithValue(ctx, resolver.ContextKey, 11)
fmt.Printf("Context address in Resolver: %p\n", &ctx)
return next(ctx)
}
```
### What did you expect?
I hope to be able to get the value through Context during Resolver, But
By reading the source code, I found that the Directive's Context was created by
```graphql.WithPathContext(ctx, graphql.NewPathWithField("fieldName")) ```
and this context was only used to return errors and was not passed to the Resolver. I tried to modify generated!. gotpl file, but the configuration file cannot modify the path of this template
### Minimal graphql.schema and models to reproduce
### versions
- `go run github.com/99designs/gqlgen version`? v0.17.40
- `go version`? 1.21.5
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.