Is is possible to get field directives in mutation hook?
- Dominant language
- Go
- Stars
- 10.8k
- Forks
- 1.3k
- Avg merge
- 2d 36m
- Merged PRs (30d)
- 26
Description
### What happened?
According to https://gqlgen.com/recipes/modelgen-hook/ we can mutate generated models file.
### What did you expect?
I want to add some tags into struct fields depending on existing directives.
### Minimal graphql.schema and models to reproduce
```gql
directive @testDirective(value: Int!) on INPUT_FIELD_DEFINITION
input SomeInput {
someField: Int! @testDirective(value: 100)
}
```
Expected struct:
```go
type SomeInput struct {
SomeField int `json:"someField" test:"100"`
}
```
### versions
- `gqlgen version`? 0.12.2
- `go version`? 1.15
- dep or go modules? go.mod
Contributor guide
Research direction
Look at the modelgen hook documentation and the code generation process in gqlgen. The mutation hook likely receives a model object; you need to inspect its fields for directives. Start by finding where the hook is invoked in the codegen package, then see how field directives are attached. Check existing tests for model generation to understand the data structures. The goal is to add directive-derived tags to struct fields in the generated Go code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, graphql
- Domain
- backend-api-design, devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100